supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
* s6 style "readiness notification" with perpd
@ 2019-04-26  1:25 Jeff
  2019-04-26  9:24 ` Laurent Bercot
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff @ 2019-04-26  1:25 UTC (permalink / raw)
  To: supervision

does s6-supervise listen to the given "readiness notification" fd ?
seems so to me.

that is the reason s6 style "readiness notification" would be hard
to do directly with perpd since it is a more integrated solution
that does not use intermediary supervise processes.

right ?




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: s6 style "readiness notification" with perpd
  2019-04-26  1:25 s6 style "readiness notification" with perpd Jeff
@ 2019-04-26  9:24 ` Laurent Bercot
  2019-04-26 15:01   ` Jeff
  0 siblings, 1 reply; 5+ messages in thread
From: Laurent Bercot @ 2019-04-26  9:24 UTC (permalink / raw)
  To: supervision

>does s6-supervise listen to the given "readiness notification" fd ?
>seems so to me.

Yes, it does.


>that is the reason s6 style "readiness notification" would be hard
>to do directly with perpd since it is a more integrated solution
>that does not use intermediary supervise processes.

  It would certainly be possible for perpd to do the same, as long
as it stays under the max open file limit - which may reduce the
maximum possible number of services, but not enough for it to be
a serious limitation.

--
  Laurent



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: s6 style "readiness notification" with perpd
  2019-04-26  9:24 ` Laurent Bercot
@ 2019-04-26 15:01   ` Jeff
  2019-04-26 15:28     ` Laurent Bercot
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff @ 2019-04-26 15:01 UTC (permalink / raw)
  To: supervision

26.04.2019, 11:43, "Laurent Bercot" <ska-supervision@skarnet.org>:
> It would certainly be possible for perpd to do the same, as long
> as it stays under the max open file limit - which may reduce the
> maximum possible number of services, but not enough for it to be
> a serious limitation.

how is that ?
what if 2 services (non-interdependent, to be started concurrently)
specify/use the same fd (number) to write their readiness notification
message to ? how could perpd tell which of the 2 nofied it ?




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: s6 style "readiness notification" with perpd
  2019-04-26 15:01   ` Jeff
@ 2019-04-26 15:28     ` Laurent Bercot
  2019-04-26 15:58       ` Jeff
  0 siblings, 1 reply; 5+ messages in thread
From: Laurent Bercot @ 2019-04-26 15:28 UTC (permalink / raw)
  To: supervision

>how is that ?
>what if 2 services (non-interdependent, to be started concurrently)
>specify/use the same fd (number) to write their readiness notification
>message to ? how could perpd tell which of the 2 nofied it ?

  It doesn't matter what the number is that the service sees. As long
as perpd creates a separate pipe for every service (which is why it
would count against the maximum number of services it can maintain),
it can read the notifications from every service separately.

  The notification-fd value used by s6-supervise is not relevant to
s6-supervise, it's only relevant to the service. It's only used
by s6-supervise at ./run spawning time, to tell what number the
*child* should dup2() the notification pipe to before execing ./run,
so the pipe is made available to the service on the fd it expects.
The supervisor itself does not use fixed fd numbers. It would be
the same with perpd.

--
  Laurent



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: s6 style "readiness notification" with perpd
  2019-04-26 15:28     ` Laurent Bercot
@ 2019-04-26 15:58       ` Jeff
  0 siblings, 0 replies; 5+ messages in thread
From: Jeff @ 2019-04-26 15:58 UTC (permalink / raw)
  To: supervision

26.04.2019, 17:27, "Laurent Bercot" <ska-supervision@skarnet.org>:
> It doesn't matter what the number is that the service sees. As long
> as perpd creates a separate pipe for every service (which is why it
> would count against the maximum number of services it can maintain),
> it can read the notifications from every service separately.

so there is a small advantage of using an intermediary supervise
child process instead of doing it in a more integrated way directly
in the perpd parent process.

of course one can run more intances of perpd on different scandirs
should the upper limit on the number of open fds be exceeded
(which is rarely the case i guess).

> The notification-fd value used by s6-supervise is not relevant to
> s6-supervise, it's only relevant to the service. It's only used
> by s6-supervise at ./run spawning time, to tell what number the
> *child* should dup2() the notification pipe to before execing ./run,
> so the pipe is made available to the service on the fd it expects.

probably fd 3 in most cases ... 

> The supervisor itself does not use fixed fd numbers. It would be
> the same with perpd.

ok, i see.
so the perpd parent process opens a pipe(2) for every such service
and does a dup(2) after fork(2) in the child process that execs into
the service run script somehow among these lines:

...

pid_t p = 0 ;
int p [ 2 ] = { -1 } ;

pipe ( p ) ;

p = fork ()

if ( 0 == p ) {
  // child process that should execve(2) into the daemon
  ... 
  dup2 ( p [ 1 ], requested_fd ) ;
  ...
  // exec into service run script
  execve ( ... ) ;
  _exit ( 111 ) ;
} else if ( 0 < p ) {
  // parent process (perpd)
  // waitpid() for child and read(2) from p [ 0 ]
} else if ( 0 > p ) {
  // fork(2) failed
}

...

dumb question anyway, my error.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-04-26 15:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-26  1:25 s6 style "readiness notification" with perpd Jeff
2019-04-26  9:24 ` Laurent Bercot
2019-04-26 15:01   ` Jeff
2019-04-26 15:28     ` Laurent Bercot
2019-04-26 15:58       ` Jeff

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).