On Wed, Apr 27, 2011 at 2:24 AM, Krishnakant Mane <[email protected]> wrote:
> On 27/04/11 06:33, Mike Orr wrote:
>>
>> I run my apps under supervisor, which is a Python daemon manager.
>>
> I would also like to use superwiser.
> Can you give some hint?
> By the way I think I must make a daemon any ways because I have to make an
> automated system where my application is started as a background process as
> soon as the machine starts.
> So I don't expect the end user to do a paster serve --daemonise
> production.ini manuall.
> Can this too be automated?
> And yes there is also this step of starting the virtual environment which
> should also be automated.
> I guess this certainly need some kind of a shell script?
> Happy hacking.
> Krishnakant.

In Ubuntu, install the 'supervisor package' and create an
/etc/supervisor/conf.d/ file for your application. Here's an example:

[program:inews]
command = /home/wwwadmin/venv/inews2.5/bin/paster serve
/home/wwwadmin/apps/inews/production.ini
process_name = inews
autostart = true
startsecs = 5
;exitcodes = 0,2
user = www-data
redirect_stderr = true
stdout_logfile = /home/wwwadmin/data/inews/error.log

Note that the 'paster' is in a virtualenv, so it'll run under the
virutalenv environment. Also note that you don't daemonize the program
yourself: Supervisor does that.

Supervisor has three main advantages over traditional init.d scripts:
- It runs the application in a child process so it doesn't need a PID
file, and it knows immediately if the application dies..
- You can start/stop/list jobs with the "supervisorctl" command (which
I symlink to "supervisor").
- It's Python!

By "end user" do you mean yourself or another sysadmin? I don't
distribute daemon applications; I just run them myself. If you need to
distribute them so that an unknowledgeable sysadmin can install them,
it's more difficult. Every OS and Linux distro is different in its
daemon configuration. If your sysadmins are all running a DEB or
RPM-based system with a 'supervisor' and 'python-virtualenv' packages
available, you can make a DEB or RPM package for them containing the
application and Supervisor conf file and a postinstall script to
create a virtualenv. Otherwise I would just give them the application
tarball and a sample Supervisor conf file, with instructions on how to
build the virtualenv and configure Supervisor.

-- 
Mike Orr <[email protected]>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to