forked from ungleich-public/cdist-contrib
__netbox_uwsgi: enable further protocols to bind to
Enables multiple protocols like fastcgi or HTTP to bind to. This makes it more flexible to use. Also, a little fix for __netbox was done: correctly output a error msg.
This commit is contained in:
parent
2805b6beff
commit
243e34f0a5
4 changed files with 55 additions and 9 deletions
|
@ -127,7 +127,7 @@ fi
|
||||||
export SMTP_USE_SSL
|
export SMTP_USE_SSL
|
||||||
if [ -f "$__object/parameter/smtp-use-tls" ]; then
|
if [ -f "$__object/parameter/smtp-use-tls" ]; then
|
||||||
if [ "$SMTP_USE_SSL" = "True" ]; then
|
if [ "$SMTP_USE_SSL" = "True" ]; then
|
||||||
echo "options --smtp-use-ssl and --smtp-use-tls are not compatible"
|
echo "options --smtp-use-ssl and --smtp-use-tls are not compatible" >&2
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
SMTP_USE_TLS="True"
|
SMTP_USE_TLS="True"
|
||||||
|
|
|
@ -2,6 +2,18 @@
|
||||||
|
|
||||||
# Generates uwsgi config
|
# Generates uwsgi config
|
||||||
# see https://uwsgi-docs.readthedocs.io/en/latest/Options.html
|
# see https://uwsgi-docs.readthedocs.io/en/latest/Options.html
|
||||||
|
# or https://uwsgi-docs-additions.readthedocs.io/en/latest/Options.html
|
||||||
|
|
||||||
|
# params:
|
||||||
|
# 1: parameter name
|
||||||
|
# 2: parameter value file
|
||||||
|
#
|
||||||
|
# output: the lines for the configuration option
|
||||||
|
multi_options() {
|
||||||
|
while read -r line; do
|
||||||
|
printf "%s = %s\n" "$1" "$line"
|
||||||
|
done < "$2"
|
||||||
|
}
|
||||||
|
|
||||||
# fix missing $__explorer
|
# fix missing $__explorer
|
||||||
# see https://code.ungleich.ch/ungleich-public/cdist/-/issues/834
|
# see https://code.ungleich.ch/ungleich-public/cdist/-/issues/834
|
||||||
|
@ -13,8 +25,21 @@ cores="$(cat "$__explorer/cpu_cores")"
|
||||||
|
|
||||||
cat << EOF
|
cat << EOF
|
||||||
[uwsgi]
|
[uwsgi]
|
||||||
; socket to bind
|
; socket(s) to bind
|
||||||
socket = $HOST
|
EOF
|
||||||
|
|
||||||
|
# special protocol to bind
|
||||||
|
for param in $(find "$__object/parameter/" -maxdepth 1 -name "*-bind" -print); do
|
||||||
|
multi_options "$(basename "$param" | awk -F'-' '{print $1}')-socket" "$param"
|
||||||
|
socket_changes=yes
|
||||||
|
done
|
||||||
|
# else, default bind to
|
||||||
|
if [ -z "$socket_changes" ]; then
|
||||||
|
multi_options "socket" "$__object/parameter/bind-to"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
cat << EOF
|
||||||
|
|
||||||
; processes and threads
|
; processes and threads
|
||||||
processes = $(( 2*cores + 1 ))
|
processes = $(( 2*cores + 1 ))
|
||||||
|
|
|
@ -9,10 +9,11 @@ cdist-type__netbox_uwsgi - Run NetBox with uWSGI
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
-----------
|
-----------
|
||||||
This (singleton) type installs uWSGI into the NetBox `python-venv`. It hosts
|
This (singleton) type installs uWSGI into the NetBox `python-venv`. It hosts
|
||||||
the NetBox WSGI application over the WSGI protocol. A further server must be
|
the NetBox WSGI application via the WSGI protocol. A further server must be
|
||||||
installed to provide it as HTTP. This application is available via the
|
installed to provide it as HTTP and serve static content. It supports multiple
|
||||||
`uwsgi-netbox` systemd service. It is controllable via the `netbox` wrapper
|
protocols like uwsgi, fastcgi or HTTP to comunicate with the proxy server. This
|
||||||
service, too.
|
application is available via the `uwsgi-netbox` systemd service. It is
|
||||||
|
controllable via the `netbox` wrapper service, too.
|
||||||
|
|
||||||
|
|
||||||
REQUIRED PARAMETERS
|
REQUIRED PARAMETERS
|
||||||
|
@ -24,7 +25,15 @@ OPTIONAL PARAMETERS
|
||||||
-------------------
|
-------------------
|
||||||
bind-to
|
bind-to
|
||||||
The socket uwsgi should bind to. Must be UNIX/TCP for the uwsgi protocol.
|
The socket uwsgi should bind to. Must be UNIX/TCP for the uwsgi protocol.
|
||||||
Defaults to ``127.0.0.1:3031``.
|
Defaults to ``127.0.0.1:3031``. Can be set multiple times.
|
||||||
|
|
||||||
|
uwsgi-bind
|
||||||
|
http-bind
|
||||||
|
fastcgi-bind
|
||||||
|
scgi-bind
|
||||||
|
Bind the application to a specific protocol instead of implicit uwsgi via
|
||||||
|
``--bind-to``. If such parameter given, ``--bind-to`` will be ignored. Must
|
||||||
|
be a UNIX/TCP socket. Can be set multiple times.
|
||||||
|
|
||||||
|
|
||||||
BOOLEAN PARAMETERS
|
BOOLEAN PARAMETERS
|
||||||
|
@ -55,10 +64,18 @@ EXAMPLES
|
||||||
__netbox $args
|
__netbox $args
|
||||||
require="__netbox" __netbox_uwsgi
|
require="__netbox" __netbox_uwsgi
|
||||||
|
|
||||||
# with special bind
|
# with multiple binds
|
||||||
|
__netbox $args
|
||||||
require="__netbox" __netbox_uwsgi --bind-to 0.0.0.0:3032 \
|
require="__netbox" __netbox_uwsgi --bind-to 0.0.0.0:3032 \
|
||||||
--bind-to 0.0.0.0:3033
|
--bind-to 0.0.0.0:3033
|
||||||
|
|
||||||
|
# with multiple protocols
|
||||||
|
# parameter `--bind-to` will be ignored
|
||||||
|
__netbox $args
|
||||||
|
require="__netbox" __netbox_uwsgi --uwsgi-bind 0.0.0.0:3031 \
|
||||||
|
--http-bind 0.0.0.0:8080 \
|
||||||
|
--fastcgi-bind 1.2.3.4:5678
|
||||||
|
|
||||||
|
|
||||||
SEE ALSO
|
SEE ALSO
|
||||||
--------
|
--------
|
||||||
|
|
|
@ -1 +1,5 @@
|
||||||
bind-to
|
bind-to
|
||||||
|
uwsgi-bind
|
||||||
|
http-bind
|
||||||
|
fastcgi-bind
|
||||||
|
scgi-bind
|
||||||
|
|
Loading…
Reference in a new issue