exit container when socat process is stopped

This commit is contained in:
Gerrit Gogel 2024-02-17 16:03:03 +01:00
parent 1e7f4d9fdd
commit eebbff419f

View file

@ -12,20 +12,20 @@ function start_seahub {
function start_socat { function start_socat {
mkdir -p /opt/seafile/seafile-server-latest/runtime mkdir -p /opt/seafile/seafile-server-latest/runtime
while true; do if ! nc -z ${SEAFILE_SERVER_HOSTNAME} 8001 2>/dev/null; then
while ! nc -z ${SEAFILE_SERVER_HOSTNAME} 8001 2>/dev/null; do echo "Failed to establish socat bridge with seafile-server on port 8001. Terminating..."
sleep 1 exit
done fi
echo "Starting socat..." echo "Starting socat..."
socat -d -d UNIX-LISTEN:/opt/seafile/seafile-server-latest/runtime/seafile.sock,fork,unlink-early TCP:${SEAFILE_SERVER_HOSTNAME}:8001,forever,keepalive,keepidle=10,keepintvl=10,keepcnt=2 socat -d -d UNIX-LISTEN:/opt/seafile/seafile-server-latest/runtime/seafile.sock,fork,unlink-early TCP:${SEAFILE_SERVER_HOSTNAME}:8001,forever,keepalive,keepidle=10,keepintvl=10,keepcnt=2
done echo "Socat process was stopped. Exiting container..."
} }
function watch_server { function watch_server {
while true; do while true; do
sleep 1 sleep 1
if ! nc -z ${SEAFILE_SERVER_HOSTNAME} 8082 2>/dev/null; then if ! nc -z ${SEAFILE_SERVER_HOSTNAME} 8082 2>/dev/null; then
echo "Lost connection to seafiler-server. Stopping seahub..." echo "Lost connection to seafile-server. Stopping seahub..."
/opt/seafile/seafile-server-latest/seahub.sh stop /opt/seafile/seafile-server-latest/seahub.sh stop
fi fi
done done