<snip />
> It would also be very useful to be able to run arbitrary commands, not
> necessarily or strictly subprocess management, on program start and/or
> stop.  A couple of things I'd like to use this for:
> 
>   - taking a load balancer back-end down before stopping and bringing it
>     back up after starting a program
>   - priming a backend with a few requests after starting and before
>     bringing the back-end back up
> 
> I've been trying to figure out what the right way to think about this
> should be.  The program should not successfully stop without first
> taking down the back-end nor should a start be considered successful
> without successfully priming the program and then bringing the back-end
> back up.  So what's the right place to do this?  Is it even possible to
> achieve this with events or a wrapper script?  Should this be something
> that supervisor core does?  Is this outside the scope of supervisor?

Thought I might share the approach we've been using: we've altered our 
wsgi server to take a sighup and subsequently do the following: finish 
all open requests, stop taking new requests, display a change to the 
status check for the load balancer that tells the load balancer to 
remove the server from the pool, a longer timeout that does a hard 
shutdown of the server after an interval.

We then use fabric to drive supervisorctl to do the actual recycling. 
Supervisord is configure to send the HUP.


def cycle_super(app, deploydir=DEPLOYDIR):
     """
     Cycle apps through supervisor
     """
     with cd(path(deploydir) / 'supervisor'):
         with hide('running', 'stdout', 'stderr'):
             out = run('bin/python bin/supervisorctl avail')
         procs = [x.split(' ', 1)[0] for x in out.split('\n')]
         with hide('running'):
             for proc in procs:
                 if proc.startswith(app):
                     run('bin/python bin/supervisorctl restart %s' %proc)
             run('bin/python bin/supervisorctl status')


This works ok, but is time constrained by the number of processes 
restarted.  Being able to parallelize this a bit would be nice (say 
cycle/4 and smartly cycle N process in N/4 groups).

That being said, just having a basic cycling command is more important 
to me than say dependency managment or concurrent cycling.

-w



-- 
 >>>
Whit Morriss
CodeMonkey
[email protected]

_______________________________________________
Supervisor-users mailing list
[email protected]
http://lists.supervisord.org/mailman/listinfo/supervisor-users

Reply via email to