forked from ungleich-public/cdist-contrib
__netbox: add wrapper service to manage the wsgi services
The wrapper service will "control" the services added from the __netbox_* types to provide a general interface. This is more dynamic than the alias approach used previously. Through this, it is possible to handle multiple wsgi services for netbox - if this works .. See as a reference: http://alesnosek.com/blog/2016/12/04/controlling-a-multi-service-application-with-systemd/
This commit is contained in:
parent
1ef4420c53
commit
9d8b3ebe74
9 changed files with 25 additions and 22 deletions
12
type/__netbox/files/netbox.service
Normal file
12
type/__netbox/files/netbox.service
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
[Unit]
|
||||||
|
Description=NetBox Service Wrapper
|
||||||
|
Documentation=https://netbox.readthedocs.io/en/stable/
|
||||||
|
After=network-online.target
|
||||||
|
Wants=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
|
@ -98,6 +98,7 @@ fi
|
||||||
if [ "$changes" = "yes" ]; then
|
if [ "$changes" = "yes" ]; then
|
||||||
cat << EOF
|
cat << EOF
|
||||||
# Restart service.
|
# Restart service.
|
||||||
|
service netbox restart
|
||||||
service netbox-rq restart
|
service netbox-rq restart
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -204,7 +204,9 @@ $SECRET_KEY
|
||||||
SECRET
|
SECRET
|
||||||
|
|
||||||
|
|
||||||
# Upload systemd unit for worker service
|
# Upload systemd unit for worker and wsgi service
|
||||||
__systemd_unit netbox-rq.service \
|
for unit in netbox netbox-rq; do
|
||||||
--source "$__type/files/netbox-rq.service" \
|
__systemd_unit $unit.service \
|
||||||
--enablement-state enabled
|
--source "$__type/files/$unit.service" \
|
||||||
|
--enablement-state enabled
|
||||||
|
done
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=NetBox Gunicorn WSGI Service
|
Description=NetBox Gunicorn WSGI Service
|
||||||
Documentation=https://netbox.readthedocs.io/en/stable/
|
Documentation=https://netbox.readthedocs.io/en/stable/
|
||||||
|
PartOf=netbox.service
|
||||||
|
After=netbox.service
|
||||||
After=network-online.target
|
After=network-online.target
|
||||||
Wants=network-online.target
|
Wants=network-online.target
|
||||||
|
|
||||||
|
@ -19,5 +21,4 @@ RestartSec=30
|
||||||
PrivateTmp=true
|
PrivateTmp=true
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
Alias=netbox.service
|
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
|
@ -19,12 +19,6 @@ if grep -q "^__file/opt/netbox/gunicorn.py:" "$__messages_in"; then
|
||||||
printf "configured\n" >> "$__messages_out"
|
printf "configured\n" >> "$__messages_out"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# application
|
|
||||||
if grep -q "^__netbox:" "$__messages_in"; then
|
|
||||||
do_restart=yes
|
|
||||||
# no message cause it should be obvious
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# restart gunicorn
|
# restart gunicorn
|
||||||
if [ "$do_restart" ]; then
|
if [ "$do_restart" ]; then
|
||||||
|
|
|
@ -37,8 +37,7 @@ updated $old to $new
|
||||||
configured
|
configured
|
||||||
Configuration for gunicorn changed.
|
Configuration for gunicorn changed.
|
||||||
|
|
||||||
In both cases, and at messages from the `__netbox` type, it restarts the
|
In both cases, it restarts the service to use the up-to-date version.
|
||||||
service to using the up-to-date version.
|
|
||||||
|
|
||||||
|
|
||||||
EXAMPLES
|
EXAMPLES
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Netbox uWSGI WSGI Service
|
Description=Netbox uWSGI WSGI Service
|
||||||
Documentation=https://netbox.readthedocs.io/en/stable/
|
Documentation=https://netbox.readthedocs.io/en/stable/
|
||||||
|
PartOf=netbox.service
|
||||||
|
After=netbox.service
|
||||||
After=network-online.target
|
After=network-online.target
|
||||||
Wants=network-online.target
|
Wants=network-online.target
|
||||||
|
|
||||||
|
@ -19,5 +21,4 @@ RestartSec=30
|
||||||
PrivateTmp=true
|
PrivateTmp=true
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
Alias=netbox.service
|
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
|
@ -19,12 +19,6 @@ if grep -q "^__file/opt/netbox/uwsgi.ini:" "$__messages_in"; then
|
||||||
printf "configured\n" >> "$__messages_out"
|
printf "configured\n" >> "$__messages_out"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# application
|
|
||||||
if grep -q "^__netbox:" "$__messages_in"; then
|
|
||||||
do_restart=yes
|
|
||||||
# no messages cause this is obvious
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# restart uwsgi
|
# restart uwsgi
|
||||||
if [ "$do_restart" ]; then
|
if [ "$do_restart" ]; then
|
||||||
|
|
|
@ -39,8 +39,7 @@ upgraded
|
||||||
configured
|
configured
|
||||||
The uwsgi configuration got updated.
|
The uwsgi configuration got updated.
|
||||||
|
|
||||||
In both cases, and at messages from the `__netbox` type, it restarts the
|
In all cases, it restarts the service to use the up-to-date version.
|
||||||
service to using the up-to-date version.
|
|
||||||
|
|
||||||
|
|
||||||
EXAMPLES
|
EXAMPLES
|
||||||
|
|
Loading…
Reference in a new issue