Bug#727708: upstart and upgrading from sysvinit scripts
On Sat, 2013-12-28 at 21:29 -0800, Russ Allbery wrote:
> Uoti Urpala <firstname.lastname@example.org> writes:
> > Does sd_notify() actually give any positive effect compared to just
> > using type=simple, given that you already have socket activation? The
> > UDP socket should buffer packets until the daemon reads them. Explicit
> > notify does have the negative effect that depending services can not be
> > started in parallel.
> > Or do you want to support running it as a systemd service but without
> > using socket activation (would seem rather pointless)? You ship a
> > .socket file by default, so it doesn't explain the use of type=notify in
> > the provided file at least.
> The thought was the latter, combined with the intent to fully explore the
> whole systemd interface. Also, there are situations where I believe that
> systemd will start the service without using socket activation even when
> socket activation is configured. For example, if I disable both lbcd and
> lbcd.socket, and then manually start lbcd.service, lbcd.socket is not
> started, which I suspect means that socket activation is not used.
Adding the mentioned Requires=lbcd.socket line should ensure that the
service is never started without the socket running. I'm quite sure that
daemons intended to run under systemd should have no need to implement
any socket-opening code themselves (unless they do something special
like opening a socket in the middle of operation); anything which would
contradict that should be a misunderstanding or a bug.
> > I think the .service file should have a Requires= on the socket to make
> > the service fail in case the socket could not be opened (probably
> > doesn't matter otherwise).
> I think I misunderstood something I read in systemd.service(5) and thought
> it said not to do that, but it was talking about something different.
> That would probably also get rid of the case that I mentioned above.
> However, daemon(7) does say:
> It is recommended to place a WantedBy=sockets.target directive in the
> [Install] section, to automatically add such a dependency on
> installation of a socket unit. Unless DefaultDependencies=no is set
> the necessary ordering dependencies are implicitly created for all
> socket units. For more information about sockets.target see
> systemd.special(7). It is not necessary or recommended to place any
> additional dependencies on socket units (for example from
> multi-user.target or suchlike) when one is installed in
> I'm not entirely sure whether "any additional dependencies on socket
> units" is meant to imply that lbcd.service should not depend on
> lbcd.socket, or if that's just talking about the [Install] section of the
> socket file itself.
That wording really is unclear. I think it must mean the latter to make
sense. Looking at the code, it seems that sockets automatically get a
"Before:" dependency on identically named services, and the rarer
explicit "Sockets:" in a .service file also adds "Wants:". So ordering
should work by default, but a "Requires:" dependency must be explicit.
I couldn't find where the automatic dependencies would be documented.