Skip to content

Instantly share code, notes, and snippets.

@toast38coza
Created June 23, 2012 09:50
Show Gist options
  • Save toast38coza/2977748 to your computer and use it in GitHub Desktop.
Save toast38coza/2977748 to your computer and use it in GitHub Desktop.
Ununtu upstart script to start django_gunicorn with New Relic
description "launch django app with gunicorn and new relic monitoring"
start on net-device-up
stop on shutdown
respawn
# this cd's into your app's base dir
chdir /var/www/<appname>/
# this sets the path to your newrelic.ini file
env NEW_RELIC_CONFIG_FILE=/var/www/<appname>/newrelic.ini
# this launches your app with gunicorn using new relic's admin tool
# note: in this case, /env/bin is my virtualenv. By running the command from your virtualenv's interpreter, you don't need to
# activate the env manually
exec /var/www/<appname>/env/bin/newrelic-admin run-program /var/www/<appname>/env/bin/gunicorn_django -w3
@toast38coza
Copy link
Author

Notes:

*you'll need to make a few changes to make the paths match your environment.

  • Will start your app on system startup
  • Will stop your app on shutdown
  • if you save this, for example, at: /etc/init/myapp.conf then: Start: start myapp. Stop: stop myapp. Restartrestart myapp

(where myapp matches to myapp.conf)

@lextoumbourou
Copy link

Thanks a lot for this.

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