aboutsummaryrefslogtreecommitdiffstats
path: root/main/uwsgi
diff options
context:
space:
mode:
authorJakub Jirutka <jakub@jirutka.cz>2016-10-12 01:48:09 +0200
committerJakub Jirutka <jakub@jirutka.cz>2016-10-12 02:31:37 +0200
commit6cc664d9ecf9d44b02dfcf66ee680c5b42a124c8 (patch)
tree06baf8c342f3e1bec79b2f4498322a00461ef285 /main/uwsgi
parent24dbdea153b18a924d75c97c0716893ec8416f61 (diff)
downloadaports-6cc664d9ecf9d44b02dfcf66ee680c5b42a124c8.tar.bz2
aports-6cc664d9ecf9d44b02dfcf66ee680c5b42a124c8.tar.xz
main/uwsgi: rewrite runscript, allow to run multiple masters
Diffstat (limited to 'main/uwsgi')
-rw-r--r--main/uwsgi/APKBUILD8
-rw-r--r--main/uwsgi/uwsgi.initd90
2 files changed, 86 insertions, 12 deletions
diff --git a/main/uwsgi/APKBUILD b/main/uwsgi/APKBUILD
index 7d4be74a91..b864ce3cc6 100644
--- a/main/uwsgi/APKBUILD
+++ b/main/uwsgi/APKBUILD
@@ -4,7 +4,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=uwsgi
pkgver=2.0.14
-pkgrel=1
+pkgrel=2
pkgdesc="uWSGI application container server"
url="http://projects.unbit.it/uwsgi/"
arch="all"
@@ -191,19 +191,19 @@ _plugin() {
}
md5sums="d4b2c7db274dc20be54a977c9b040b7e uwsgi-2.0.14.tar.gz
-808aa42f536b7d4dd9dd966b1f25d690 uwsgi.initd
+242f0193721c5c92f835240297a7d6f5 uwsgi.initd
a797ffed638ea797a16557d963598fb2 uwsgi.ini
cf4242f1a6cd8182a91d5c27dc688fe1 readme.emperor
98407f45c566a2c39a34b882e1ac9fe4 alpine.buildconf
87c16f6fe482c9b0eac0d33c51873f45 musl-fix-python.patch"
sha256sums="21b3d1ef926d835ff23576193a2c60d4c896d8e21567850cf0677a4764122887 uwsgi-2.0.14.tar.gz
-319be0fdbce036351cdc4b60eac821400b5b2ba7dcfac246867dfde1e295fa74 uwsgi.initd
+8578aeecf80a337293366ab49b568efddd3edf465aa54540ea62384c53fd8c3f uwsgi.initd
b9cc5a3590b95854eb563fbb84b3e0f54d25ea6d222585a1b40583a6913cc911 uwsgi.ini
bad9480a81d57baaef1d228713837f5dae81f93527c436aeb1ed5ed8dad58f54 readme.emperor
31fc9c17f17aa067c3b025a3f7a84c6102d24368afcbc237f3d58041083c0875 alpine.buildconf
3838e8e3926a1f6271bb5aa88d309837a3bcd06cd570c499b72ca549326c682e musl-fix-python.patch"
sha512sums="cf557ba27cb1c28e784e8909043bca874cd56846aa9ebaf1ff229191ad20484e467147a6ea7cc629399d4afd6e4ac4479b2f6827729df04321eef4bf842b9e42 uwsgi-2.0.14.tar.gz
-4e4bab0082ed22df37fb4081431f6b42d93ed76f279b61c8d4014a20e695c224082ad4bad35ca624cbb95cb787d43894daf09398f8102b556c7034ab0ba58e9b uwsgi.initd
+1d195524efbf90d4c7e66507a5d61d874f896f69088977118f37051907227fe6b1a6fc6795500148ed20d63d854892b1b2497c13c52626402da3389a550851a5 uwsgi.initd
370202e143d0e041a2e36905346080d3ca592c9a74705a8c4e142a1307d22b921c10e673d683ca284ea27d184474ed86edd7723a6e590d35a562ad7cf6afa529 uwsgi.ini
2798c9d2e49e29292ffe6a5a29b866301c78d5f322fc5d07dfa9569efdaa5220237a5f6744652fbdd957be29311ddaff190541333f042cbf0e907dfa98ce3e2a readme.emperor
f3cff00926929a5bb40afafb65fd5228582af35fbf524562282020c4c4ae9c659231b2381f4b3cceb18e8f3f6c888c21bdd8ed4ddcd81e92fbc6a0891800ce38 alpine.buildconf
diff --git a/main/uwsgi/uwsgi.initd b/main/uwsgi/uwsgi.initd
index 7a22e648c5..8502ebba1a 100644
--- a/main/uwsgi/uwsgi.initd
+++ b/main/uwsgi/uwsgi.initd
@@ -1,16 +1,90 @@
#!/sbin/openrc-run
-name="uwsgi"
-command="/usr/sbin/uwsgi"
-command_args="--ini /etc/uwsgi/uwsgi.ini --daemonize=/var/log/uwsgi/uwsgi.log"
-retry="INT/30/KILL/5"
-start_stop_daemon_args="--quiet"
+# If you want to run multiple separate processes, then create symlinks to
+# this runscript (e.g. uwsgi.myapp or myapp) and configure options in
+# the corresponding conf.d files. uWSGI options can be specified as variables
+# prefixed with "uwsgi_" (e.g. uwsgi_chmod_socket=640 -> --chmod-socket=640).
+
+: ${pidfile:="/run/$RC_SVCNAME/uwsgi.pid"}
+
+extra_started_commands='reload stats'
+description_reload='Gracefully reload all the workers and the master process'
+description_stats='Dump uWSGI statistics to log file'
+
+command='/usr/sbin/uwsgi'
+command_args="--die-on-term"
+command_background='yes'
+start_stop_daemon_args='--quiet'
+retry='INT/30/KILL/5'
+
+if [ "$RC_SVCNAME" = 'uwsgi' ]; then
+ : ${name:="uWSGI emperor"}
+ emperor='yes'
+else
+ : ${name:="uWSGI application ${RC_SVCNAME#uwsgi.}"}
+ emperor='no'
+fi
depend() {
- need net
+ need net
+ use apache2 lighttpd nginx
+ after postgresql
}
start_pre() {
- checkpath --directory --owner uwsgi:uwsgi \
- --mode 0775 /run/uwsgi /var/log/uwsgi
+ if [ "$emperor" = 'yes' ]; then
+ : ${logfile:="/var/log/uwsgi/uwsgi.log"}
+ : ${user:="root"}
+ else
+ : ${user:="nobody"}
+ command_args="$command_args --master"
+ fi
+ start_stop_daemon_args="$start_stop_daemon_args
+ --user $user
+ $(optif --group "$group")
+ $(optif --stdout "$logfile")
+ $(optif --stderr "$logfile")"
+
+ if [ -z "$uwsgi_conf" ]; then
+ case "$RC_SVCNAME" in
+ uwsgi) uwsgi_conf='/etc/uwsgi/uwsgi.ini';;
+ uwsgi.*) uwsgi_conf="/etc/uwsgi/conf.d/${RC_SVCNAME#uwsgi.}";;
+ *) uwsgi_conf="/etc/$RC_SVCNAME/uwsgi";;
+ esac
+ fi
+
+ if [ -f "${uwsgi_conf%.ini}.ini" ]; then
+ command_args="$command_args --ini ${uwsgi_conf%.ini}.ini"
+ elif [ -f "${uwsgi_conf%.yml}.yml" ]; then
+ command_args="$command_args --yaml ${uwsgi_conf%.yml}.yml"
+ fi
+
+ # Convert variables "uwsgi_<opt_name>=<value>" into "--<opt-name>=<value>".
+ local uwsgi_opts="$(set | grep -v '^uwsgi_conf=' \
+ | sed -En 's/^uwsgi_([^=]+)=(.*)/--\1=\2 /p' \
+ | sed -E ':s; s/^([^=]*)_([^=]*)=(.*)$/\1-\2=\3/; t s;')"
+ command_args="$command_args $uwsgi_opts"
+
+ checkpath -d -m 755 -o $user:$group \
+ "$(dirname "$pidfile")" "$(dirname "$logfile")"
+
+ if yesno "$EINFO_VERBOSE"; then
+ einfo "Command: $command $(printf '%s ' $command_args)"
+ fi
+}
+
+reload() {
+ ebegin "Reloading $name"
+ start-stop-daemon --signal HUP --pidfile "$pidfile"
+ eend $?
+}
+
+stats() {
+ ebegin "Dumping statistics for $name to the log file"
+ start-stop-daemon --signal USR1 --pidfile "$pidfile"
+ eend $?
+}
+
+optif() {
+ test -n "$2" && printf "%s %s\n" "$1" "$2"
}