Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Upstart doesn't like to start gunicorn because it tries to call setpgrp (see github issue), what would be the best way to start [gunicorn] on a 10.04.1 server install? - Ideally with automatic restarting of the failed main process and multiple workers. On the gunicorn site they mention [runit] and [supervisord], is it worthwhile installing another kind of process supervisor alongside ubuntu's upstart?

I'll document progress here after exams if someone doesn't come up with a better solution.

OK I've tried:

respawn
respawn limit 10 5

expect daemon # also tried expect fork

exec python /path/to/manage.py run_gunicorn --daemon

but I can't seem to get the job to start, it just hangs? nothing shows up in ps aux | grep manage or the syslog, I'm guessing upstart isn't catching the fork properly. Is it because I'm using manage.py instead of gunicorn directly? I'll give running it directly a shot as soon as I get a chance.

Clarification: manage.py is from a django 1.2 instance with gunicorn as an installed app, but no special settings in settings.py (I don't know the syntax for specifying gunicorns port/address/workers in settings.py so I was planning to just use cmdline args)

share|improve this question
add comment

2 Answers

I've just commented in the github issue as well.

Since there seems to be some issue with setpgrp and gunicorn, you may have better results if you run it with

expect fork

Added to the upstart job definition.

so something like

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

respawn
expect fork

exec /path/to/gunicorn --daemon

Should work well.

'man 5 init' is a wealth of information and should help understand why things work this way.

share|improve this answer
    
man 5 init was very helpful, thanks! –  adonm Nov 8 '10 at 4:35
add comment

We just pushed a patch to Gunicorn master [1] that will allow you to use Gunicorn with Upstart. You shouldn't need to use any of the "expect fork" configuration directives with this version.

[1] https://github.com/benoitc/gunicorn

share|improve this answer
add comment

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.