On Fri, Feb 13, 2015 at 8:35 PM, Tim Tisdall <[email protected]> wrote:

>
> https://uwsgi-docs.readthedocs.org/en/latest/WSGIquickstart.html#automatically-starting-uwsgi-on-boot
>
> That has links to start up scripts for upstart and systemd.  I'll post
> what I use for init.d when I'm in front of a computer.
>

I think I posted an init script to the list before, but I had to modify it
because Debian 7 changed it's "run" directory to be on a tmpfs.  You could
also just make the pid file appear in /run/ without a subdirectory, though.

#! /bin/bash
### BEGIN INIT INFO
# Provides:          uwsgi_project
# Required-Start:    $local_fs $remote_fs $networking
# Required-Stop:     $local_fs $remote_fs $networking
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Starts uwsgi_project
# Description:       Starts and stops uwsgi_project as needed
### END INIT INFO
# /etc/init.d/uwsgi_project
#

daemon=/sites/project/env/bin/uwsgi
pid=/run/uwsgi/project.pid
args="--ini /sites/project/development_uwsgi.ini --ini-paste
/sites/project/development.ini"
me=`basename $0`

check_privsep_dir() {
    # Create the PrivSep empty dir if necessary
    if [ ! -d /run/uwsgi ]; then
    mkdir -p -m0777 /run/uwsgi
    fi
}

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

exit 0
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi

Reply via email to