Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I host a few Django sites on one of my Ubuntu servers. Up until recently I've been using the Cherokee HTTPd which has the option to launch back-end applications like Django sites but I've just switched out to nginx.

Under cherokee, I just "run" Django sites (sites are stored in /web/):

cd /web/mywebsite/; python manage.py runfcgi workdir=/web/mywebsite method=threaded socket=/web/mywebsite/sock pidfile=/web/mywebsite/pid maxspare=3 maxrequests=500

And then I'd connect to the socket at /web/mywebsite/sock. Cherokee also runs this as a user of my choice, in my case www-data.

This approach has worked well for me under Cherokee but now I'm moving to nginx, I don't have something there holding my hand for process management.

Looking around, there are literally hundreds of different ways of managing this. Init scripts, cron checks, daemontools. But as I'm on Ubuntu (and probably always will be) Upstart seems to make sense... But where do I start?

Could somebody give me an example of a upstart script that runs the above and will respawn it if it dies?

I have several django sites sitting in /web/ (and they're the only directories in that directory) so if there's a cheaty way that I can get this one upstart script to launch them all (with the same settings) and monitor them, that would be super-extra-awesome.

share|improve this question

1 Answer 1

I use same config, /etc/init/django.conf:

description "Django FastCGI /web site"

start on runlevel [2345]
stop on runlevel [!2345]

respawn
exec python /web/manage.py runfcgi socket=//web/mywebsite/sock pidfile=/var/run/django.pid

control:

start: start django or initctl start django
stop: stop django or initctl stop django
restart: restart django or initctl restart django

I recently recorded a video about configure nginx and django(fastcgi and upstart) - http://linux.dyndns-work.com/video/ubuntu_server10.04_install_django_nginx_fastcgi.ogv/

But I prefer nginx and uwsgi(also upstart init script) - no link, i can post a maximum of one hyperlink.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.