Skip to content

Instantly share code, notes, and snippets.

@jeremyjbowers
Created December 31, 2012 01:29
Show Gist options
  • Save jeremyjbowers/4416665 to your computer and use it in GitHub Desktop.
Save jeremyjbowers/4416665 to your computer and use it in GitHub Desktop.
This is an upstart configuration file to execute uWSGI as a daemon on Ubuntu-recent (10.x, 12.x). For more info on upstart: http://upstart.ubuntu.com/getting-started.html. This file would live in /etc/init/ and you'd need to do sudo initctl reload-configuration on the initial file creation and then sudo service my_app start/restart/stop to contr…
description "uWSGI server for electris CMS"
start on runlevel [2345] # start on all runlevels.
stop on runlevel [!2345] # stop when shutting down.
respawn # respawn if job crashes or is stopped ungracefully.
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
/usr/local/bin/uwsgi \ # 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.
@gerardjp
Copy link

On line 14 you say directory of this application. I assume you mean django project? .. Django supporting nested apps under a project. 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment