aboutsummaryrefslogtreecommitdiff
path: root/netbox/etc/service/netbox-rq/run
blob: aa4b675b35dea1b87f4bee05b6c875c6097093ee (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

/sbin/su-exec netbox /usr/bin/python3 /opt/netbox/netbox/manage.py rqworker &

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