The Gunicorn type now supports systemd sockets only. With uWSGI, you can choose between it and the native sockets based on the parameters chosen. This is done because it could not be implemented to have multiple protocols with the systemd sockets (so you may choose). The systemd socket unit file is generally available, so both types use the same script to generate the socket unit file.
57 lines
1.3 KiB
Bash
Executable file
57 lines
1.3 KiB
Bash
Executable file
#!/bin/sh -e
|
|
# __netbox_gunicorn/manifest
|
|
|
|
# Check states
|
|
state=""
|
|
unit_state=""
|
|
param_state="$(cat "$__object/parameter/state")"
|
|
|
|
case "$param_state" in
|
|
enabled|disabled)
|
|
state="present"
|
|
unit_state="$param_state"
|
|
;;
|
|
|
|
absent)
|
|
state="absent"
|
|
unit_state="disabled"
|
|
;;
|
|
|
|
*)
|
|
# does not exist
|
|
printf "The state '%s' does not exist, can't continue!\n" "$param_state" >&2
|
|
exit 2
|
|
;;
|
|
esac
|
|
|
|
|
|
mkdir "$__object/files"
|
|
|
|
if [ "$state" = "present" ]; then
|
|
# process template
|
|
"$__type/files/gunicorn.py.sh" > "$__object/files/gunicorn.py"
|
|
|
|
# gunicorn config file
|
|
__file /opt/netbox/gunicorn.py \
|
|
--mode 644 --owner netbox \
|
|
--source "$__object/files/gunicorn.py"
|
|
|
|
else
|
|
# absent config file
|
|
__file /opt/netbox/gunicorn.py --state absent
|
|
fi
|
|
|
|
|
|
TYPE="Gunicorn"
|
|
export TYPE
|
|
|
|
"$__type/files/netbox.socket.sh" "$__object/parameter/bind-to" \
|
|
> "$__object/files/netbox.socket"
|
|
|
|
# install systemd files
|
|
__systemd_unit gunicorn-netbox.socket \
|
|
--state "$state" --enablement-state "$unit_state" \
|
|
--source "$__object/files/netbox.socket" --restart
|
|
__systemd_unit gunicorn-netbox.service \
|
|
--state "$state" --enablement-state "$unit_state" \
|
|
--source "$__type/files/netbox.service" --restart
|