supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
From: KORN Andras <korn@elan.rulez.org>
To: supervision@list.skarnet.org
Subject: Re: Customised control help
Date: Tue, 1 Jan 2008 11:29:29 +0100	[thread overview]
Message-ID: <20080101102928.GE19934@utopia.intra.guy> (raw)
In-Reply-To: <loom.20080101T081035-510@post.gmane.org>

On Tue, Jan 01, 2008 at 08:27:34AM +0000, Rehan Khan wrote:

Hi,

> Customize Control
>  For each control character c sent to the control pipe, runsv first checks if 
> service/control/c exists and is executable. If so, it starts service/control/c 
> and waits for it to terminate, before interpreting the command. If the program 
> exits with return code 0, runsv refrains from sending the service the 
> corresponding signal. The command o is always considered as command u. On 
> command d first service/control/t is checked, and then service/control/d. On 
> command x first service/control/t is checked, and then service/control/x. The 
> control of the optional log service cannot be customized.
> 
> I have a couple of questions:
> 
> 1) are all the control codes supported? Not just the ones in the above 
> paragraph? (h, 1, 2, etc)

Yes.

> 2) I have the t script for some of my services. Do I have to send a term 
> manually after I have run the pre-term commands I need (i.e do I have to do 

No. Just make sure your script exits with a nonzero exit status.

> 3) (Not directly related to the above.). I have a service called bluetooth 
> which starts up the hcid process. The normal fedora init script runs some 
> commands after the hcid daemon starts (using hciattach command). If the 
> service starts successfully how can I run these post start commands within the 
> runit method instead of in a separate script. I would like to keep everything 
> a service does in the service directory. (I could background and disown 
> another script with a sleep pre-pended but this is not a particularly clean 
> implementation)

Depending on what exactly those post-commands are, you could put them in a
'check' script; sv start would invoke that repeatedly until it exits
successfully or until it times out. Make sure the script is idempotent and
that it doesn't screw anything up badly if it's invoked when hcid is down.

I think it would be better to write a new service called e.g.
'bluetooth-postinit' or something, make it 'normally down' (i.e. 'touch
./down') and make its run script do something like this:

#!/bin/sh
exec 2>&1
sv start bluetooth || exit 1
#
# post-commands go here
#
exec sv down .

The bluetooth run script should then do:

[...]
sv up bluetooth-postinit
exec chpst [args] hcid [args]

And if hcid isn't necessarily 'up' just because it's running, also write a
'check' script for the 'bluetooth' service that exits successfully IIF hcid
is ready.

> 4) Is there a more detailed description of customised control somewhere? 

Not that I know of.

Andras

-- 
                 Andras Korn <korn at chardonnay.math.bme.hu>
                 <http://chardonnay.math.bme.hu/~korn/>	QOTD:
              Life is much easier if you look at the source code.


  reply	other threads:[~2008-01-01 10:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-01  8:27 Rehan Khan
2008-01-01 10:29 ` KORN Andras [this message]
2008-01-01 16:29 ` Charlie Brady
     [not found] ` <14AE52C8045C4D1F9AC27FD137DA0657@home.internal>
2008-01-02  6:44   ` rehan khan
2008-01-02 10:42     ` KORN Andras
2008-01-02 14:41     ` Charlie Brady
     [not found]     ` <0DEDB6FEF7B44A7C8C121C2E41C63F43@home.internal>
2008-01-02 17:03       ` rehan khan
2008-01-02 17:37         ` Charlie Brady
     [not found]         ` <CE0657F3ABAE4CE5B8C8E594928A8067@home.internal>
2008-01-03  4:33           ` rehan khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080101102928.GE19934@utopia.intra.guy \
    --to=korn@elan.rulez.org \
    --cc=supervision@list.skarnet.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).