Re: how to wrap properly a Red Hat / CentOS service into a daemontools service ?

Brian Reichert <[email protected]> Tue, 4 Jan 2011 12:04:24 -0500
Newsgroups gmane.comp.djb.syslog
Message-ID <[email protected]>
On Tue, Jan 04, 2011 at 05:17:35PM +0100, Romain Pelisse wrote:
> I want to use daemontools to deploy alls my application including some
> already packaged servers such as nginx. As those kind of services are
> already packaged by the distribution (in my case, CentOS), I wonder which
> approach should I use to deploy them as daemontools service. Should I just
> ensure the service is stopped and wrote myself a custom script or should
> somehow wrap the existing script (/etc/init.d/nginx) into a smaller run
> script to daemontools will run ?

I've done some work doing this same thing.  Here's my general
framework , but I'd certainly be curious to hear how others have
handled this:

- generate a run script for each service that runs it in the foreground.

- write a SysV init script that ends up under init.d

- include the ckhconfig directives, so you can make use of 'service
  foo status' and so forth.

- _exclude_ your runlevel from said directives; you want daemontools
  to initiate this service, not rc.init.

The last step may not be important to you; I like letting things
start up in parallel, not serially.

I went so far as to have my SysV init scripts make use of a central
set of bash functions that would block until the service in question
was 'stopped' and 'started'; that made use of lsof to see if a named
resource (network port, for example) was consumed by the process
managed by service directory.  This is important to our management
framework, but it's up to you.

As we were maintaining a Linux-based appliance, all software
installation was managed by RPMs via kickstart.  As such, I created
RPMs named 'foo-daemontools' that tackled the work of:

- dropping in the service directory for the foo service
- renaming CentOS's stock /etc/init.d/foo with my own
- managing the new service under certain conditions.

and so forth.  I don't know how you're managing your platform, so
you may not care about such steps...

> 
> -- 
> Romain PELISSE,
> *"The trouble with having an open mind, of course, is that people will
> insist on coming along and trying to put things in it" -- Terry Pratchett*
> http://belaran.eu/wordpress/belaran

-- 
Brian Reichert				<[email protected]>
55 Crystal Ave. #286			
Derry NH 03038-1725 USA			BSD admin/developer at large