-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
27 lines (22 loc) · 678 Bytes
/
Copy pathstart.sh
File metadata and controls
27 lines (22 loc) · 678 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
set -e
# Start Gunicorn (Python API) in the background
gunicorn server:app \
--bind 127.0.0.1:8000 \
--workers 1 \
--preload \
--timeout 120 \
--log-level info \
--access-logfile - \
--error-logfile - &
GUNICORN_PID=$!
# If Nginx exits for any reason, kill Gunicorn too (and vice versa)
# This ensures Docker sees a non-zero exit and restarts the container
trap "kill $GUNICORN_PID 2>/dev/null; exit" INT TERM
# Start Nginx in foreground — keeps container alive
nginx -g "daemon off;" &
NGINX_PID=$!
# Wait for either process to exit; kill the other one
wait -n 2>/dev/null || true
kill $GUNICORN_PID $NGINX_PID 2>/dev/null
exit 1