aboutsummaryrefslogtreecommitdiff
path: root/code-host/etc/service/nginx/run
blob: 79dcaf1c61696cdd43393d5924a163f5f4288276 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh

# runsv sends us a TERM but uwsgi will only shutdown cleanly
# if it receives an INT so we need to translate the signal
# properly for uwsgi
trap 'kill -INT $PID' TERM

/nginx_bootstrap /usr/sbin/nginx -g "daemon off;" &

PID=$!

# wait for uwsgi, will get cancelled when runsv TERMs us and
# the trap will get executed next, unless something goes wrong
# and uwsgi fails then this wait will run
wait $PID

# if something went wrong then unregister the trap because it
# won't have a target
trap - TERM

# waiting on a dead process will return the return code of the
# processes original exit
wait $PID