Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add proxy_snapshot_internal #315

Merged
merged 2 commits into from
May 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions proxy_snapshot_internal/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Proxy Snapshot Internal

Similar to `proxy_snapshot` but used for internal services. While `proxy_snapshot` is for public or external usage.

37 changes: 37 additions & 0 deletions proxy_snapshot_internal/docker_service_create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# usage: ./docker_service_create.sh swarm_node
# eg., ./docker_service_create.sh cosmosia1

swarm_node="$1"

if [[ -z $swarm_node ]]
then
echo "No swarm_node. usage eg., ./docker_service_create.sh cosmosia1"
exit
fi

SERVICE_NAME="proxysnapshotinternal_$swarm_node"

# delete existing service
docker service rm $SERVICE_NAME

# create new service
docker service create \
--name $SERVICE_NAME \
--replicas 1 \
--mount type=bind,source=/mnt/data/snapshots,destination=/snapshots,readonly \
--constraint "node.hostname==${swarm_node}" \
--network net1 \
--network net2 \
--network net3 \
--network net4 \
--network net5 \
--network net6 \
--network net7 \
--network net8 \
--endpoint-mode dnsrr \
--restart-condition none \
--env-file ../env.sh \
archlinux:latest \
/bin/bash -c \
"curl -s https://raw.githubusercontent.com/notional-labs/cosmosia/main/proxy_snapshot_internal/run.sh > ~/run.sh && \
/bin/bash ~/run.sh"
63 changes: 63 additions & 0 deletions proxy_snapshot_internal/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

#user http;
worker_processes auto;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;


events {
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;

# fix: could not build optimal types_hash, you should increase either types_hash_max_size: 1024 or types_hash_bucket_size: 64; ignoring types_hash_bucket_size
types_hash_max_size 4096;
server_names_hash_bucket_size 512;

# resolver 127.0.0.11 valid=30s; # Docker's DNS server

server {
listen 11111;
server_name localhost;
#charset koi8-r;

#access_log logs/host.access.log main;
root /usr/share/nginx/html;

location / {
root /snapshots;
autoindex on;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}
17 changes: 17 additions & 0 deletions proxy_snapshot_internal/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# functions
loop_forever () {
echo "loop forever for debugging only"
while true; do sleep 5; done
}

cd $HOME
pacman -Syu --noconfirm
pacman -Sy --noconfirm nginx

echo "#################################################################################################################"
echo "nginx..."

curl -Ls "https://raw.githubusercontent.com/notional-labs/cosmosia/main/proxy_snapshot_internal/nginx.conf" > /etc/nginx/nginx.conf
/usr/sbin/nginx

loop_forever