mirror of
https://github.com/ggogel/seafile-containerized.git
synced 2024-11-16 17:05:32 +00:00
seahub: improved lifecycle management
Exits container if seahub or socat exits or if connection to seafile-server is lost. It is recommended to set the restart policy for the container to "unless-stopped".
This commit is contained in:
parent
94d3ed3e9e
commit
bfeaa2188f
|
@ -23,30 +23,36 @@ function start_socat {
|
|||
|
||||
function watch_server {
|
||||
while true; do
|
||||
sleep 2
|
||||
if ! nc -z ${SEAFILE_SERVER_HOSTNAME} 8082 2>/dev/null; then
|
||||
/opt/seafile/seafile-server-latest/seahub.sh stop
|
||||
while ! nc -z ${SEAFILE_SERVER_HOSTNAME} 8082 2>/dev/null; do
|
||||
sleep 1
|
||||
if ! nc -z ${SEAFILE_SERVER_HOSTNAME} 8082 2>/dev/null; then
|
||||
echo "Lost connection to seafiler-server. Stopping seahub..."
|
||||
/opt/seafile/seafile-server-latest/seahub.sh stop
|
||||
fi
|
||||
done
|
||||
start_seahub &
|
||||
}
|
||||
|
||||
function watch_seahub {
|
||||
while true; do
|
||||
sleep 1
|
||||
if ! pgrep -f "seahub.wsgi:application" >/dev/null; then
|
||||
echo "Seahub process was stopped. Exiting container..."
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function logger {
|
||||
tail -f /opt/seafile/logs/seahub.log | tee /proc/1/fd/1
|
||||
tail -f /opt/seafile/logs/seahub.log | tee
|
||||
}
|
||||
|
||||
function keep_running {
|
||||
while true; do
|
||||
tail -f /dev/null & wait ${!}
|
||||
done
|
||||
}
|
||||
init_seahub
|
||||
start_seahub
|
||||
|
||||
start_socat &
|
||||
init_seahub
|
||||
start_seahub &
|
||||
watch_server &
|
||||
logger
|
||||
keep_running
|
||||
watch_seahub &
|
||||
logger &
|
||||
|
||||
wait -n
|
||||
|
||||
exit $?
|
Loading…
Reference in a new issue