-
Notifications
You must be signed in to change notification settings - Fork 10
/
uwsgi-kill
executable file
·33 lines (33 loc) · 1.04 KB
/
uwsgi-kill
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh
# uwsgi-kill (part of ossobv/vcutil) // wdoekes/2014-2018 // Public Domain
#
# Sends the HUP signal to the parent uwsgi(-core) process to make it
# restart all children. Instead of doing /etc/init.d/uwsgi restart, this
# is quicker (less downtime).
#
# As an added bonus, you can select which parent you want to HUP by
# adding arguments.
#
# Usage:
#
# uwsgi-kill
# # HUPs all uwsgi parents
#
# uwsgi-kill somesite
# # HUPs the uwsgi parent that matches "somesite"
#
# See also:
#
# uwsgi-list
#
args=$(echo "$*" |
sed -e 's#[^[:blank:]A-Za-z0-9]#[^A-Za-z0-9]#g;s#[[:blank:]]\+#.*#')
parents=$(pgrep -d, -xf '/usr/bin/uwsgi.*/emperor.ini( .*)?')
pids=$(pgrep -d, -P${parents:-1} -xf "^/usr/bin/uwsgi.*[^A-Za-z0-9]$args.*$")
test -z "$pids" && echo "Nothing matches..." >&2 && exit 1
echo "Sending restart signal to uwsgi(-cores):"
ps hf -p $pids | sed -e '
s#^\([[:blank:]]*[0-9]\+\) .* /usr/bin/uwsgi[^ ]* # \1 uwsgi #
s# /\([^ /]\+/\)*# #g' | sort -k2 |
grep --color=auto -C100 "$args"
kill -HUP $(echo $pids | tr , ' ')