On Wed, Aug 10, 2016 at 05:27:09PM +0200, Christian Svensson wrote:
> Hi,
> 
> As far as I understand, right now the daemonizing flow for an OVS process
> is:
> 
> 1. Process calls daemonize_start to fork into a child if running in
> detached mode
> Parent waits until daemonize_complete is called
> 
> 2. Child (or parent if not daemonized) executes initialization
> 
> 3. daemonize_complete is called when the process is confident that the
> initialization was successful.
> This causes the parent process to exit (or no-op if not daemonized).
> 
> This is all well for processes using --detach and 'Type=forking' in systemd
> world.
> However, the recommended practice is not to use forking but to use
> systemd's notifications - calling sd_notify.
> 
> Would a patch to call sd_notify be welcome? Obviously this would be gated
> on if the system has systemd (--with-systemd etc.).
> 
> The patch I'm thinking would be to add:
> #ifdef HAVE_SYSTEMD
> sd_notify(0, "READY=1");
> #endif
> in daemonize_complete (or other place if a better one is suggested).
> And the equivalent for Python of course.
> 
> For further reading and discussions by smarter people than me for other
> daemons:
> https://sourceware.org/ml/libc-alpha/2014-02/msg00732.html
> https://sourceware.org/ml/libc-alpha/2014-02/msg00738.html
> https://lists.debian.org/debian-ssh/2015/05/msg00017.html

The second message above says:

    2. Exit of the parent process.  This requires a forking service model,
       which has various drawbacks and which essentially all init systems
       written after the classic shell script init system have tried to move
       away from.  This allows you to detect all errors that can be detected
       before the fork, but requires some sort of internal IPC mechanism to
       tell the parent process when to exit if you want to detect errors that
       happen after the fork.  This is the most common historical method, but
       it's usually incorrectly implemented because getting the details right
       is hard.

       All widely-used init systems support this method.

This is how OVS works.

What's the advantage of sd_notify?  You say that sd_notify() is
"recommended".  By whom, and where?  And with what benefit?

Thanks,

Ben.
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to