From: Gerrit Pape <pape@smarden.org>
Cc: Dra?en Ka?ar <dave@fly.srk.fer.hr>
Subject: Re: graceful restart under runit
Date: Fri, 17 Nov 2006 13:14:59 +0000 [thread overview]
Message-ID: <20061117131500.8646.qmail@da1eefc0778e36.315fe32.mid.smarden.org> (raw)
In-Reply-To: <20061116152446.GA4721@fly.srk.fer.hr>
On Thu, Nov 16, 2006 at 04:24:46PM +0100, Dra?en Ka?ar wrote:
> Alex Efros wrote:
> > On Wed, Nov 15, 2006 at 12:47:54PM +0100, Dra?en Ka?ar wrote:
> > > Say I have a TCP server which listens on incoming connections on some TCP
> > > port. Occasionaly I'd like to install and run a new version of the server
> > > executable. Server source is under my control, for all intents and
> > > purposes.
> > [...]
> > > Is there a way to get around this?
> >
> > Probably you can just fork() after receiving SIGUSR1 and exit from parent
> > leaving child to process existing connection.
Yes.
> Servers which use process per connection do something like that already
> (the parent process signals the children, exits and leaves them to finish
> sessions and then they exit too).
>
> However, there are multithreaded monsters which can't do that. fork()
> replicates just the calling thread[1], so it's not an option and exit()
> will terminate all threads (ie. all sessions).
Hm, even though I too dislike "multithreaded monsters", we could add
some detach support to runsv, e.g. the patch below. You can test this
with
$ printf f >./supervise/control
After this, runsv forgets about the child, and considers the service to
be terminated; custom/f, if it exists, will be run before detaching.
Regards, Gerrit.
Index: src/runsv.c
===================================================================
RCS file: /cvs/runit/src/runsv.c,v
retrieving revision 1.26
diff -u -r1.26 runsv.c
--- src/runsv.c 24 Jul 2006 21:01:37 -0000 1.26
+++ src/runsv.c 17 Nov 2006 12:58:34 -0000
@@ -359,6 +359,15 @@
update_status(s);
if (! s->pid) startservice(s);
break;
+ case 'f': /* forget, detach */
+ if (! s->pid) break;
+ custom(s, c);
+ s->pid =0;
+ s->state =S_DOWN;
+ s->ctrl =C_NOOP;
+ pidchanged =1;
+ update_status(s);
+ break;
case 'a': /* sig alarm */
if (s->pid && ! custom(s, c)) kill(s->pid, SIGALRM);
break;
prev parent reply other threads:[~2006-11-17 13:14 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-15 11:47 Dražen Kačar
2006-11-15 16:08 ` Alex Efros
2006-11-16 15:24 ` Dražen Kačar
2006-11-17 0:15 ` Alex Efros
2006-11-17 0:48 ` Paul Jarc
2006-11-17 13:34 ` Alex Efros
2006-11-17 14:53 ` Charlie Brady
2006-11-17 15:39 ` Gerrit Pape
2006-11-18 0:22 ` Alex Efros
2006-11-18 1:34 ` Charlie Brady
2006-11-18 12:31 ` Alex Efros
2006-11-18 19:30 ` Paul Jarc
2006-11-20 18:27 ` Dražen Kačar
2006-11-20 19:32 ` Paul Jarc
2006-11-20 19:43 ` Paul Jarc
2006-11-22 19:25 ` Dražen Kačar
2006-11-22 19:51 ` Paul Jarc
2006-11-23 12:25 ` Dražen Kačar
2006-11-24 21:22 ` Paul Jarc
2006-11-17 13:14 ` Gerrit Pape [this message]
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=20061117131500.8646.qmail@da1eefc0778e36.315fe32.mid.smarden.org \
--to=pape@smarden.org \
--cc=dave@fly.srk.fer.hr \
/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).