[systemd-devel] .service and .socket

Reindl Harald h.reindl at thelounge.net
Wed Jan 2 11:39:40 UTC 2019



Am 02.01.19 um 12:12 schrieb Michael Chapman:
> On Wed, 2 Jan 2019, Reindl Harald wrote:
>> Am 02.01.19 um 11:49 schrieb Michael Chapman:
>>> On Wed, 2 Jan 2019, Reindl Harald wrote:
>>> [...]
>>>> 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
>>
>> first can you please reply only to the list so that the duplicate
>> message-filter don't rip the later coming list message after your
>> off-list copy was received breaking my reply-to-list button and threading?
> 
> I'll try to remember, but I'm likely to forget. (I use Reply-all for much 
> the reasons described in [1]. I also prefer _receiving_ Reply-all emails
> [1] http://david.woodhou.se/reply-to-list.html

get a proper mail client which knows what to do with "List-Post:
<mailto:systemd-devel at lists.freedesktop.org>" headers

http://mailman13.u.washington.edu/pipermail/alpine-info/2014-June/005974.html

>>> Presumably things in [Unit] would only apply to the socket. What if the 
>>> service needs [Unit] directives itself? Do we really want yet another 
>>> special case ("you can embed the service inside the socket... but only if 
>>> the service doesn't need [Unit] directives")?
>>
>> why would they need only apply to the socket?
> 
> Well, consider things like After= and Before=. Yes, you could make those 
> only apply to both the socket and the service, but it wouldn't make much 
> sense. In fact, they probably should only apply to the service.

why?

there is one unit which just contains a [service] section

> But then you've got the special case that [Unit] directives inside a file 
> whose name matches *.socket don't apply to the socket, if and only if the 
> file also contains a [Service] section.
> 
> I would find that confusing.

there is no need for any distinction to begin with

when you want different directives for the two parts just use a .service
and a .socket unit as you are forced to do now and you are done and when
not use a .socket unit with a [service] section

it's that easy



More information about the systemd-devel mailing list