aboutsummaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
authorJakub Jirutka <jakub@jirutka.cz>2017-07-13 22:52:02 +0200
committerJakub Jirutka <jakub@jirutka.cz>2017-07-13 23:04:00 +0200
commit142873633d4ae1d139e12289e8ce50e960839447 (patch)
tree06bcadcd88b1ee078998d277a4174d4f50317650 /testing
parentf6b30c12fcc2003579f0364001666815f452e919 (diff)
downloadaports-142873633d4ae1d139e12289e8ce50e960839447.tar.bz2
aports-142873633d4ae1d139e12289e8ce50e960839447.tar.xz
testing/py-waitress: add runscript
Diffstat (limited to 'testing')
-rw-r--r--testing/py-waitress/APKBUILD16
-rw-r--r--testing/py-waitress/waitress.confd58
-rw-r--r--testing/py-waitress/waitress.initd75
3 files changed, 145 insertions, 4 deletions
diff --git a/testing/py-waitress/APKBUILD b/testing/py-waitress/APKBUILD
index ec3b610862..e54d95b528 100644
--- a/testing/py-waitress/APKBUILD
+++ b/testing/py-waitress/APKBUILD
@@ -3,7 +3,7 @@
pkgname=py-waitress
_pkgname=waitress
pkgver=1.0.2
-pkgrel=0
+pkgrel=1
pkgdesc="A Python WSGI server"
url="https://github.com/Pylons/waitress"
arch="noarch"
@@ -11,7 +11,9 @@ license="ZPL-2.1"
checkdepends="py-nose"
makedepends="python2-dev python3-dev py-setuptools"
subpackages="py2-$_pkgname:_py2 py3-$_pkgname:_py3"
-source="https://files.pythonhosted.org/packages/source/${_pkgname:0:1}/$_pkgname/$_pkgname-$pkgver.tar.gz"
+source="https://files.pythonhosted.org/packages/source/${_pkgname:0:1}/$_pkgname/$_pkgname-$pkgver.tar.gz
+ waitress.initd
+ waitress.confd"
builddir="$srcdir/$_pkgname-$pkgver"
build() {
@@ -30,8 +32,12 @@ check() {
package() {
mkdir -p "$pkgdir"/usr/bin
+ cd "$pkgdir"
- ln -s waitress-serve-3 "$pkgdir"/usr/bin/waitress-serve
+ ln -s waitress-serve-3 usr/bin/waitress-serve
+
+ install -D -m 755 "$srcdir"/waitress.initd etc/init.d/waitress
+ install -D -m 644 "$srcdir"/waitress.confd etc/conf.d/waitress
}
_py2() {
@@ -58,4 +64,6 @@ _py() {
rm -R usr/lib/python$pyver*/site-packages/$_pkgname/tests
}
-sha512sums="b7000e1198ac306ce189f70c5dcfcf41318e5ec47c8d6183cdbc360c8759ca726405d5da70f1c7fe3cfeb39d528af94d693767c2a7a1a7fe460c6407857ec6f0 waitress-1.0.2.tar.gz"
+sha512sums="b7000e1198ac306ce189f70c5dcfcf41318e5ec47c8d6183cdbc360c8759ca726405d5da70f1c7fe3cfeb39d528af94d693767c2a7a1a7fe460c6407857ec6f0 waitress-1.0.2.tar.gz
+d91df5fcd7e1224b1c5808402270edea5638cb958ce9fc5a5a2bdf69d12f1a4632679af7727f8ddabc222b1eb2152509ae06a8d194eace0dc32380b21195ecba waitress.initd
+93d3abe2226a396c60435875d3fefbdc0eaff2b5e6d7e98d33944f9b8167bf965ae20bb967407de668726cef2ab824b5a11e8c8b7babbc94ba0e451f07f6a178 waitress.confd"
diff --git a/testing/py-waitress/waitress.confd b/testing/py-waitress/waitress.confd
new file mode 100644
index 0000000000..0c94736f15
--- /dev/null
+++ b/testing/py-waitress/waitress.confd
@@ -0,0 +1,58 @@
+# YOU SHOULD NOT MODIFY THIS FILE! CREATE A COPY NAMED AFTER THE APPLICATION
+# YOU WANT TO RUN AND MODIFY THAT INSTEAD (and remove this notice).
+
+# Python executable to run waitress-serve with.
+#python="/usr/bin/python3"
+
+# User to run the application.
+#user="nobody"
+
+# Path of the log file to catch stdout/stderr of the process.
+logfile="/var/log/$RC_SVCNAME.log"
+
+
+# Base directory of the application.
+#basedir=
+
+# Name of the application's WSGI module (python file typically inside $basedir).
+wsgi_module="wsgi"
+
+# Name of attribute in $wsgi_module that contains WSGI object
+# or factory function.
+#wsgi_object="application"
+
+# Call the given object to get the WSGI application.
+#wsgi_call="no"
+
+
+# Tell waitress to listen on an ip port combination(s).
+# Example: listen="127.0.0.1:8080 [::1]:8080 *:8181"
+listen_on="*:8080"
+
+# Path of Unix socket. If a socket path is specified, a Unix domain socket is
+# made instead of the usual inet domain socket.
+#unix_socket_path=
+
+# Octal permissions to use for the Unix domain socket. Default is 600.
+#unix_socket_perms=
+
+# Default wsgi.url_scheme value. Default is "http".
+#url_scheme=
+
+# The SCRIPT_NAME WSGI environment value.
+# Setting this to anything except the empty string will cause the WSGI
+# SCRIPT_NAME value to be the value passed minus any trailing slashes you add,
+# and it will cause the PATH_INFO of any request which is prefixed with this
+# value to be stripped of the prefix. Default is the empty string.
+#url_prefix=
+
+# Server identity used in the "Server" header in responses.
+# Default is "waitress".
+#server_ident=
+
+# Extra options for waitress-serve.
+# See https://docs.pylonsproject.org/projects/waitress/en/latest/runner.html.
+#extra_opts=
+
+# Note: If you need to pass some environment variables to the application, set
+# start_stop_daemon_args="--env FOO=bar --env BAZ=qux"
diff --git a/testing/py-waitress/waitress.initd b/testing/py-waitress/waitress.initd
new file mode 100644
index 0000000000..afb76fdef6
--- /dev/null
+++ b/testing/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'"
+}