Created
December 31, 2015 09:51
-
-
Save sahilsk/fb8897a549db0be033ca to your computer and use it in GitHub Desktop.
Upstart script for python apps
This file contains hidden or 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
# vim: filetype=upstart | |
env UWSGI_BIN=/home/ubuntu/www/example_app/current/venv/bin/uwsgi | |
env PYTHONPATH=/home/ubuntu/www/example_app/current | |
env NEW_RELIC_CONFIG_FILE=/etc/newrelic/newrelic.ini | |
env NEW_RELIC_ADMIN=/usr/local/bin/newrelic-admin | |
expect fork | |
umask 0000 | |
start on runlevel [2345] | |
stop on runlevel [!2345] | |
script | |
exec $NEW_RELIC_ADMIN run-program $UWSGI_BIN --single-interpreter \ | |
--enable-threads --master --socket /tmp/example_app.sock \ | |
--socket 0.0.0.0:1719 --disable-logging --reload-on-exception \ | |
--pp $PYTHONPATH -H $PYTHONPATH/venv \ | |
-w app:app --buffer-size 32768 -p 14 -O 2 \ | |
>>/var/log/example_app.log 2>&1 & | |
end script |
This file contains hidden or 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
description "uWSGI server for Python Apps" | |
start on runlevel [2345] # start on all runlevels. | |
stop on runlevel [!2345] # stop when shutting down. | |
expect fork | |
umask 0000 | |
respawn # respawn if job crashes or is stopped ungracefully. | |
env UWSGI_BIN=/home/ubuntu/www/hawk/venv/bin/uwsgi | |
env PYTHONPATH=/home/ubuntu/www/hawk # Parent folder where app resides | |
env DEPLOYMENT_TARGET=production # set any environment variables you like here. | |
env DJANGO_SETTINGS_FILE=conf/settings.py # more environment variables if you like. | |
env PYTHONPATH=/home/ubuntu/apps/my_app:/home/ubuntu/.virtualenv/my_app | |
script # execute this block as a script | |
exec $UWSGI_BIN \ # path to the uwsgi binary | |
--virtualenv /home/ubuntu/.virtualenv/my_app \ # use a virtualenv | |
--chdir /home/ubuntu/apps/my_app \ # change to the directory of this application. | |
--file wsgi.py \ # the location of your wsgi file. | |
--touch-reload /home/ubuntu/apps/my_app/wsgi.py \ # file to touch-to-reload the application. | |
--callable app \ # are you using flask or some such? you might need a callable. | |
--logto /var/log/uwsgi.log \ # write to a log. make sure this exists or bad things happen. | |
--die-on-term \ # if the process is terminated, kill anything left over. | |
-p 1 \ # one process. you'll want 8-12 of these in production, possibly more. | |
-s :9000 # listen to the network socket 9000. | |
end script # end the script block. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment