diff --git a/docker/init_scripts/init b/docker/init_scripts/init index ff0a3be14..7233826cc 100755 --- a/docker/init_scripts/init +++ b/docker/init_scripts/init @@ -37,7 +37,12 @@ error_log () { start_bin_gunicorn () { # cleanup potentially leftover socket rm /tmp/gunicorn.sock -f - # Commands to start our main application and store its PID to check for crashes + + # recreate the socket file and ensure it has correct permissions + touch /tmp/gunicorn.sock + chmod 777 /tmp/gunicorn.sock + + # commands to start our main application and store its PID to check for crashes info_log "starting gunicorn" gunicorn \ --access-logfile - \ @@ -106,6 +111,14 @@ watchdog_process_pid () { fi } +wait_for_gunicorn_socket () { + info_log "waiting for gunicorn socket file..." + while [ ! -S /tmp/gunicorn.sock ]; do + sleep 1 + done + info_log "gunicorn socket file found" +} + # switch to backend directory cd /backend || { error_log "/backend directory doesn't seem to exist"; } @@ -135,11 +148,12 @@ while true; do debug_log "database schema already upgraded during current container lifecycle" fi - # Start nginx if we dont have a corresponding PID file - watchdog_process_pid bin nginx - # Start uvicorn if we dont have a corresponding PID file watchdog_process_pid bin gunicorn + wait_for_gunicorn_socket + + # Start nginx if we dont have a corresponding PID file + watchdog_process_pid bin nginx # only start the watcher.py if we actually want to use the rescan on fs change feature if [[ ${ENABLE_RESCAN_ON_FILESYSTEM_CHANGE} == "true" ]]; then