seafile-server: improved lifecycle management and scheduled gc

Exits container if seafile-server or socat exits. Exits the container after scheduled garbage collection. These changes allow a clean restart with deterministic behaviour. It is recommended to set the restart policy for the container to "unless-stopped".
This commit is contained in:
Gerrit Gogel 2024-02-14 11:05:59 +01:00
parent bfeaa2188f
commit 2a176d2d12
3 changed files with 15 additions and 12 deletions

View file

@ -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

View file

@ -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
wait -n
while [ -f /tmp/gc_active ]; do
sleep 10
done
exit $?

View file

@ -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}"