Last active
August 29, 2015 13:56
-
-
Save bitzip/8877626 to your computer and use it in GitHub Desktop.
uwsgi service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
set -e | |
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin | |
DESC="uwsgi daemon" | |
UWSGI_DAEMON=/var/www/xcloud_site/xcloud_env/bin/uwsgi | |
UWSGI_CONF=/etc/uwsgi/uwsgi.ini | |
UWSGI_PID=/var/run/uwsgi-emperor.pid | |
# Gracefully exit if the package has been removed. | |
test -x $UWSGI_DAEMON || exit 0 | |
d_start() { | |
if [ -f $UWSGI_PID ]; then | |
echo "uwsgi is already running" | |
else | |
nohup $UWSGI_DAEMON --ini $UWSGI_CONF --pidfile $UWSGI_PID > /dev/null 2>&1 || echo "cannot start uwsgi (maybe is already running)" & | |
fi | |
} | |
d_stop() { | |
sleep 2 | |
if [ -f $UWSGI_PID ]; then | |
kill 9 `cat $UWSGI_PID` || echo "cannot kill uwsgi!!! (maybe is not running)" | |
rm -f $UWSGI_PID | |
fi | |
} | |
d_reload() { | |
$UWSGI_DAEMON --reload $UWSGI_PID || echo "can't reload uwsgi" | |
} | |
case "$1" in | |
start) | |
echo -n "Starting $DESC..." | |
d_start | |
echo " Done" | |
;; | |
stop) | |
echo -n "Stopping $DESC..." | |
d_stop | |
echo " Done" | |
;; | |
reload) | |
echo -n "Reloading $DESC configuration..." | |
d_reload | |
echo " Done" | |
;; | |
restart) | |
echo -n "Restarting $DESC..." | |
d_stop | |
sleep 1 | |
d_start | |
echo " Done" | |
;; | |
*) | |
echo "Usage: $0 {start|stop|reload|restart}" >&2 | |
exit 3 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment