[uWSGI] Init script for Debian?

Gilles codecomplete at free.fr
Thu Apr 24 13:55:22 CEST 2014


On Wed, 23 Apr 2014 11:05:49 -0400, Tim Tisdall
<tisdall at gmail.com> wrote:
>Here's what I use on debian (not upstart.  it's an executable in
>/etc/init.d/):

Thanks Tim.

I used the following...
==================
#! /bin/bash
### BEGIN INIT INFO
# Provides:          uwsgi
# Required-Start:    $local_fs $networking
# Required-Stop:     $local_fs $networking
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Starts uwsgi
# Description:       Starts and stops uwsgi
### END INIT INFO
# /etc/init.d/uwsgi
#

daemon=/tmp/uwsgi-2.0.3/uwsgi
pid=/var/run/uwsgi.pid
args="--ini /tmp/uwsgi-2.0.3/myapp.ini"

# Carry out specific functions when asked to by the system
case "$1" in
    start)
        echo "Starting uwsgi"
        start-stop-daemon -p $pid --start --exec $daemon -- $args
        ;;
    stop)
        echo "Stopping script uwsgi"
        start-stop-daemon --signal QUIT -p $pid --stop $daemon --
$args
        ;;
    reload | restart)
        echo "Restarting worker threads"
        kill -HUP $(cat $pid)
        ;;
    *)
        echo "Usage: /etc/init.d/uwsgi {start|stop|reload}"
        exit 1
    ;;
esac

exit 0
==================


... but when typing "/etc/init.d/uwsgi start", I have to hit CTRL+C to
go back to the shell prompt:
==================
# /etc/init.d/uwsgi start
Starting uwsgi
...
spawned uWSGI worker 2 (pid: 19387, cores: 2)
spawned uWSGI worker 3 (pid: 19388, cores: 2)
spawned uWSGI worker 4 (pid: 19389, cores: 2)
*** Stats server enabled on 127.0.0.1:9191 fd: 18 ***
spawned uWSGI http 1 (pid: 19394)

^CSIGINT/SIGQUIT received...killing workers...
gateway "uWSGI http 1" has been buried (pid: 19394)
worker 1 buried after 0 seconds
worker 2 buried after 0 seconds
worker 3 buried after 0 seconds
worker 4 buried after 0 seconds
goodbye to uWSGI.
#
==================

Why doesn't the script run in the background?



More information about the uWSGI mailing list