diff options
Diffstat (limited to 'netbox/etc/service/netbox-rq/run')
-rwxr-xr-x | netbox/etc/service/netbox-rq/run | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/netbox/etc/service/netbox-rq/run b/netbox/etc/service/netbox-rq/run new file mode 100755 index 0000000..aa4b675 --- /dev/null +++ b/netbox/etc/service/netbox-rq/run | |||
@@ -0,0 +1,23 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # runsv sends us a TERM but uwsgi will only shutdown cleanly | ||
4 | # if it receives an INT so we need to translate the signal | ||
5 | # properly for uwsgi | ||
6 | trap 'kill -INT $PID' TERM | ||
7 | |||
8 | /sbin/su-exec netbox /usr/bin/python3 /opt/netbox/netbox/manage.py rqworker & | ||
9 | |||
10 | PID=$! | ||
11 | |||
12 | # wait for uwsgi, will get cancelled when runsv TERMs us and | ||
13 | # the trap will get executed next, unless something goes wrong | ||
14 | # and uwsgi fails then this wait will run | ||
15 | wait $PID | ||
16 | |||
17 | # if something went wrong then unregister the trap because it | ||
18 | # won't have a target | ||
19 | trap - TERM | ||
20 | |||
21 | # waiting on a dead process will return the return code of the | ||
22 | # processes original exit | ||
23 | wait $PID | ||