[systemd-devel] .service and .socket
Michael Chapman
mike at very.puzzling.org
Wed Jan 2 06:31:35 UTC 2019
On Tue, 1 Jan 2019, Olaf van der Spek wrote:
> Hi,
>
> AFAIK socket units require a separate file, which seems more complex
> then it has to be.
>
> 1. Could sockets be specified directly in the .service file?
If anything, I should think it would work the other way around: a .socket
without any activatable .service is relatively useless.
But I'm not proposing that this actually be implemented.
> 2. If not, could the .service file gain a default / implicit
> dependency on the .socket file?
There are a some reasons for not having a .service dependent upon its
.socket. Many services can be started directly and will work correctly
even when not passed any sockets from systemd.
> 3. AFAIK Install.WantedBy doesn't have a default. Could it get a proper default?
That doesn't make much sense.
Take your example:
> xhp.service:
> [Unit]
> Requires=xhp.socket
>
> [Install]
> WantedBy=default.target
>
> xhp.socket:
> [Socket]
> ListenStream=/run/xhp.socket
This would start xhp.service at daemon startup (i.e. boot, for the system
daemon) whether or not the service is actually required. One of the
reasons for using socket activation is to _not_ start services when
they're not required.
More information about the systemd-devel
mailing list