aboutsummaryrefslogtreecommitdiffstats
path: root/community/py-waitress/waitress.initd
diff options
context:
space:
mode:
Diffstat (limited to 'community/py-waitress/waitress.initd')
-rw-r--r--community/py-waitress/waitress.initd75
1 files changed, 75 insertions, 0 deletions
diff --git a/community/py-waitress/waitress.initd b/community/py-waitress/waitress.initd
new file mode 100644
index 0000000000..afb76fdef6
--- /dev/null
+++ b/community/py-waitress/waitress.initd
@@ -0,0 +1,75 @@
+#!/sbin/openrc-run
+
+: ${user:="nobody"}
+: ${python:="/usr/bin/python3"}
+: ${wsgi_module:=}
+: ${wsgi_object:="application"}
+: ${wsgi_call:="no"}
+
+command="$python"
+command_args="${command_args:-} /usr/bin/waitress-serve"
+command_background="yes"
+
+pidfile="/run/$RC_SVCNAME.pid"
+start_stop_daemon_args="
+ --interpreted
+ --user $user
+ ${group:+--group $group}
+ ${basedir:+--chdir $basedir}
+ ${start_stop_daemon_args:-}"
+
+depends() {
+ need net
+ after postgresql
+}
+
+start_pre() {
+ local waitress_args=""
+
+ if [ "$RC_SVCNAME" = "waitress" ]; then
+ ewarn "You are not supposed to run this runscript directly. Instead, you should"
+ ewarn "create a symlink for the application you want to run as well as a copy of"
+ ewarn "the configuration file and modify it appropriately, like so:"
+ ewarn ""
+ ewarn " ln -s waitress /etc/init.d/myapp"
+ ewarn " cp /etc/conf.d/waitress /etc/conf.d/myapp"
+ ewarn ""
+ fi
+
+ if [ -z "$wsgi_module" ]; then
+ eerror '$wsgi_module must be set!'; return 1
+ fi
+
+ if [ -n "${logfile:-}" ]; then
+ start_stop_daemon_args="$start_stop_daemon_args
+ --stdout $logfile --stderr $logfile"
+ checkpath -f -m 0644 -o $user "$logfile"
+ fi
+
+ if [ -n "$unix_socket_path" ]; then
+ checkpath -d -m 0755 -o $user "${unix_socket_path%/*}"
+ fi
+
+ if yesno "$wsgi_call"; then
+ waitress_args="$waitress_args --call"
+ fi
+
+ local item; for item in ${listen_on:-}; do
+ waitress_args="$waitress_args --listen='$item'"
+ done
+
+ waitress_args="$waitress_args
+ $(optif --unix-socket "$unix_socket_path")
+ $(optif --unix-socket-perms "$unix_socket_perms")
+ $(optif --url-scheme "$url_scheme")
+ $(optif --url-prefix "$url_prefix")
+ $(optif --ident "$server_ident")
+ ${extra_opts:-}
+ $wsgi_module:$wsgi_object"
+
+ command_args="$command_args $waitress_args"
+}
+
+optif() {
+ test -n "$2" && printf %s "$1='$2'"
+}