[systemd-devel] .service and .socket

Reindl Harald h.reindl at thelounge.net
Wed Jan 2 10:36:08 UTC 2019



Am 02.01.19 um 11:05 schrieb Lennart Poettering:
> On Di, 01.01.19 13:46, Olaf van der Spek (ml at vdspek.org) wrote:
>> AFAIK socket units require a separate file, which seems more complex
>> then it has to be.
> 
> The main reason why socket and service units are separate is that this
> way they may be separately scheduled. i.e. a socket can be established
> early and only when it is triggered the matching service is pulled in
> with all its dependencies which might delay its activation. The socket
> hence can have entirely different dependencies, properties, timings,
> lifecycles than the activated services, and that's a *good* thing

agreed, but why can't have socket simply optional a [Service] section to
save the "demo at .service" in cases like below?

[root at client:/etc/systemd/system]$ cat demo.socket
[Unit]
Description=Demo Server - Activation Socket

[Socket]
Accept=yes
ListenStream=0.0.0.0:7
ListenStream=0.0.0.0:19
ListenStream=0.0.0.0:21

[Service]
Type=oneshot
ExecStart=/usr/bin/echo "DEMO-SERVICE"
StandardOutput=socket
StandardInput=socket

[Install]
WantedBy=sockets.target


More information about the systemd-devel mailing list