diff --git a/seafile-server/scripts/gc.sh b/seafile-server/scripts/gc.sh index 92fc02d..df3d4a7 100644 --- a/seafile-server/scripts/gc.sh +++ b/seafile-server/scripts/gc.sh @@ -3,6 +3,7 @@ source /scripts/utils.sh SEAFILE_DIR=/opt/seafile/seafile-server-latest if [[ $SEAFILE_SERVER != *"pro"* ]]; then + touch /tmp/gc_active echo "Seafile CE: Stop Seafile to perform offline garbage collection." stop_socat $SEAFILE_DIR/seafile.sh stop @@ -17,8 +18,7 @@ fi $SEAFILE_DIR/seaf-gc.sh "$@" if [[ $SEAFILE_SERVER != *"pro"* ]]; then - echo "Seafile CE: Offline garbage collection completed. Starting Seafile." - sleep 3 - $SEAFILE_DIR/seafile.sh start - start_socat & + echo "Seafile CE: Offline garbage collection completed. Exiting..." + echo "Set the restart policy of this container to unless-stopped to restart it automatically after garbage collection." + rm -f /tmp/gc_active fi diff --git a/seafile-server/scripts/start.sh b/seafile-server/scripts/start.sh index 561be8e..e3d2ee5 100644 --- a/seafile-server/scripts/start.sh +++ b/seafile-server/scripts/start.sh @@ -3,8 +3,17 @@ source /scripts/utils.sh trap 'sigterm' SIGTERM -gc_cron & +rm -f /tmp/gc_active + +gc_cron start_server & start_socat & logger & -keep_running \ No newline at end of file + +wait -n + +while [ -f /tmp/gc_active ]; do + sleep 10 +done + +exit $? \ No newline at end of file diff --git a/seafile-server/scripts/utils.sh b/seafile-server/scripts/utils.sh index 6099fc0..41c4d31 100644 --- a/seafile-server/scripts/utils.sh +++ b/seafile-server/scripts/utils.sh @@ -47,12 +47,6 @@ function logger { tail -f /opt/seafile/logs/common.log | tee } -function keep_running { - while true; do - tail -f /dev/null & wait ${!} - done -} - function sig_kill_all () { pkill -SIGKILL -f "seaf-server -c ${default_ccnet_conf_dir}" pkill -SIGKILL -f "fileserver -c ${default_ccnet_conf_dir}"