fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Fab-user] sudo and background task


From: Jordi Funollet
Subject: Re: [Fab-user] sudo and background task
Date: Sun, 14 Jun 2009 01:13:15 +0200
User-agent: KMail/1.11.2 (Linux/2.6.28-11-generic; KDE/4.2.2; x86_64; ; )

Jeff is correct about that a process running in background is **not** a daemon 
mainly because it's attached to the tty. You can see a working example and a 
lot of info here, probably it's the most classic pythonic reference about the 
subject:

  http://code.activestate.com/recipes/278731/

There's a 'python-daemon' on the Cheeseshop but I never tried it. And if you 
are already working with Django you don't need it.

The way I run my Django applications on production is with Supervisord 
(http://supervisord.org/). Supervisord takes care of the Django applications 
when the machine boots/halts and gives you a command-line interface for 
controlling them. Then, all I need in the fabfile is something like:

 def stop():
     "Stop FCGI."
     sudo("supervisorctl stop fcgi-myapp")

 def start():
     "Start FCGI."
     sudo("supervisorctl start fcgi-myapp")

And that's how the Supervisord config looks (just the more "interesting" 
part):

 [program:fcgi-myapp]
 user=jordif
 environment=PYTHONPATH=/usr/local/lib/django-trunk,
    DJANGO_SETTINGS_MODULE=settings
 command=/home/jordif/apps/myapp/manage.py runfcgi
      daemonize=false host=127.0.0.1 port=3000 minspare=1 maxspare=1

I'm far more productive by configuring Supervisord than writing an 
/etc/init.d/ script for every new application I deploy. It's one of those 
tools I really like.

But I agree with Jeff: running the Django HTTP server for anything other than 
testing is a Bad Thing (TM). ;-) Don't play with this too long or it will bite 
you.

-- 
##############################
### Jordi Funollet
### http://www.terraquis.net





reply via email to

[Prev in Thread] Current Thread [Next in Thread]