Re: [Nbd] [PATCH] nbd-server: add -D/-dont-daemonize option
- To: "Dmitry V. Levin" <ldv@...1147...>
- Cc: email@example.com
- Subject: Re: [Nbd] [PATCH] nbd-server: add -D/-dont-daemonize option
- From: Goswin von Brederlow <goswin-v-b@...186...>
- Date: Mon, 25 Jun 2012 15:31:45 +0200
- Message-id: <87lijb1pry.fsf@...860...>
- In-reply-to: <20120625112206.GA1518@...1147...> (Dmitry V. Levin's message of "Mon, 25 Jun 2012 15:22:06 +0400")
- References: <20120624230358.GA28298@...1147...> <87pq8n1zlb.fsf@...860...> <20120625112206.GA1518@...1147...>
"Dmitry V. Levin" <ldv@...1147...> writes:
> On Mon, Jun 25, 2012 at 11:59:44AM +0200, Goswin von Brederlow wrote:
>> "Dmitry V. Levin" <ldv@...1147...> writes:
>> > + <term><option>-D</option></term>
>> > + <listitem>
>> > + <para>Do not detach and do not become a daemon. This allows
>> > + easy monitoring by service managers like systemd.</para>
>> > + </listitem>
>> > + </varlistentry>
>> > + <varlistentry>
>> > <term><option>-d</option></term>
>> > <listitem>
>> > - <para>Do not fork. Useful for debugging.</para>
>> > + <para>Do not fork at all. Useful for debugging.</para>
>> > </listitem>
>> > </varlistentry>
>> > <varlistentry>
>> I think the difference between -D and -d should be made clearer.
>> With -d the server runs in the foreground and accepts a single
>> connection only and outputs debug infos, right?
>> With -D the server runs in the foreground but forks a child for every
>> connect, right?
>> Also why should systemd care? It uses cgroups to monitor services. Isn't
>> that one of the advantages of systemd over all the other service
> The "simple" service type (when the service doesn't daemonize) has an
> advantage: systemd can reliably differentiate between main process and
> its children.
>> What I would like to see is socket activation in nbd-server. That way
>> the service can be started as needed without performance loss (other
>> than the initial startup time once).
> That shouldn't be a problem because nbd-server supports inetd mode.
That isn't the same. In inetd mode a new server is started up for every
incoming connection. That means overhead every time someone connects.
The socket activation is a one time thing. Systemd opens up the
listening socket so others can connect and then hands off the socket to
the daemon when it starts up. Any future connects are completly handled
by the running nbd-server.
Note: inetd has some mode for that too but hardly any daemon supports
that. Most, like nbd-server, only support the single connect on stdin
Socket activation also means that you can easily implement restarting
the daemon and hand over the existing sockets without even temporary
shutting down the service.