From d57269e905f7faeb1ef6459640adc3de6c425217 Mon Sep 17 00:00:00 2001 From: Gerrit Gogel Date: Sun, 31 Jan 2021 14:49:48 +0100 Subject: [PATCH 1/4] add netcat --- seahub/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/seahub/Dockerfile b/seahub/Dockerfile index 2eb2681..c972efb 100644 --- a/seahub/Dockerfile +++ b/seahub/Dockerfile @@ -66,7 +66,8 @@ openjpeg \ tiff \ tk \ mariadb-dev \ -libmemcached +libmemcached \ +netcat-openbsd COPY --from=get /tmp/seafile-server*/seahub /opt/seafile/seafile-server-latest/seahub COPY --from=get /tmp/seafile-server*/runtime /opt/seafile/seafile-server-latest/runtime From 308646ad5c365652d85f10b3ef1e1a8a8adeee70 Mon Sep 17 00:00:00 2001 From: Gerrit Gogel Date: Sun, 31 Jan 2021 14:50:13 +0100 Subject: [PATCH 2/4] run socat in endless loop, watch seafile-server --- seahub/scripts/start.sh | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/seahub/scripts/start.sh b/seahub/scripts/start.sh index e191a4d..486a011 100644 --- a/seahub/scripts/start.sh +++ b/seahub/scripts/start.sh @@ -1,16 +1,35 @@ #!/bin/bash -function start_seahub { +function init_seahub { /scripts/create_data_links.sh - echo "{ \"email\": \"${SEAFILE_ADMIN_EMAIL}\",\"password\": \"${SEAFILE_ADMIN_PASSWORD}\"}" | tee /opt/seafile/conf/admin.txt - #/opt/seafile/seafile-server-latest/seahub.sh start + echo "{ \"email\": \"${SEAFILE_ADMIN_EMAIL}\",\"password\": \"${SEAFILE_ADMIN_PASSWORD}\"}" | tee /opt/seafile/conf/admin.txt |& tee /dev/null python3 /opt/seafile/seafile-server-latest/check_init_admin.py +} + +function start_seahub { + echo "Starting seahub..." python3 /opt/seafile/seafile-server-latest/seahub/manage.py runserver 0.0.0.0:8000 } function start_socat { mkdir -p /opt/seafile/seafile-server-latest/runtime - socat -d -d UNIX-LISTEN:/opt/seafile/seafile-server-latest/runtime/seafile.sock,fork TCP:seafile-server:8001,forever,keepalive,keepidle=10,keepintvl=10,keepcnt=2 + while true; do + socat -d -d UNIX-LISTEN:/opt/seafile/seafile-server-latest/runtime/seafile.sock,fork TCP:seafile-server:8001,forever,keepalive,keepidle=10,keepintvl=10,keepcnt=2 + done +} + +function watch_server { + while true; do + if ! nc -z seafile-server 8001 2>/dev/null; then + echo "Seafile server is unreachable. Stopping seahub..." + pkill -f manage.py + while ! nc -z seafile-server 8001 2>/dev/null; do + sleep 1 + done + start_seahub & + fi + sleep 1 + done } function keep_running { @@ -20,5 +39,7 @@ function keep_running { } start_socat & +init_seahub start_seahub & +watch_server & keep_running \ No newline at end of file From cb4f5e93c8ee72d495877c08c101fc3deb3dfb43 Mon Sep 17 00:00:00 2001 From: Gerrit Gogel Date: Sun, 31 Jan 2021 14:52:23 +0100 Subject: [PATCH 3/4] run socat in endless loop, watch seafile-server --- seahub/scripts/start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seahub/scripts/start.sh b/seahub/scripts/start.sh index 486a011..def0ee7 100644 --- a/seahub/scripts/start.sh +++ b/seahub/scripts/start.sh @@ -2,7 +2,7 @@ function init_seahub { /scripts/create_data_links.sh - echo "{ \"email\": \"${SEAFILE_ADMIN_EMAIL}\",\"password\": \"${SEAFILE_ADMIN_PASSWORD}\"}" | tee /opt/seafile/conf/admin.txt |& tee /dev/null + echo "{ \"email\": \"${SEAFILE_ADMIN_EMAIL}\",\"password\": \"${SEAFILE_ADMIN_PASSWORD}\"}" | tee /opt/seafile/conf/admin.txt python3 /opt/seafile/seafile-server-latest/check_init_admin.py } From 13cfadb07bd8febe134726ddbee3a8fc163df19c Mon Sep 17 00:00:00 2001 From: Gerrit Gogel Date: Sun, 31 Jan 2021 14:56:03 +0100 Subject: [PATCH 4/4] do not echo admin.txt to stdout --- seahub/scripts/start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seahub/scripts/start.sh b/seahub/scripts/start.sh index def0ee7..dc4d8d6 100644 --- a/seahub/scripts/start.sh +++ b/seahub/scripts/start.sh @@ -2,7 +2,7 @@ function init_seahub { /scripts/create_data_links.sh - echo "{ \"email\": \"${SEAFILE_ADMIN_EMAIL}\",\"password\": \"${SEAFILE_ADMIN_PASSWORD}\"}" | tee /opt/seafile/conf/admin.txt + echo "{ \"email\": \"${SEAFILE_ADMIN_EMAIL}\",\"password\": \"${SEAFILE_ADMIN_PASSWORD}\"}" >/opt/seafile/conf/admin.txt python3 /opt/seafile/seafile-server-latest/check_init_admin.py }