[Whonix-devel] [Install] for static systemd unit file?
Patrick Schleizer
adrelanos at riseup.net
Thu Mar 2 01:42:00 CET 2017
Michael Biebl:
> Am 01.03.2017 um 23:58 schrieb Patrick Schleizer:
>> Michael Biebl:
>>> Am 01.03.2017 um 21:51 schrieb Patrick Schleizer:
>>>> Michael Biebl:
>>>>> Am 01.03.2017 um 21:35 schrieb Patrick Schleizer:
>>>>>> Hi!
>>>>>>
>>>>>> TLDR:
>>>>>>
>>>>>> How should the [Install] section for static systemd unit file
look like?
>>>>>
>>>>> The obvious question is: why does this service need to be statically
>>>>> enabled?
>>>>
>>>> Given the example... With this socket / service file combination, I
>>>> wouldn't know how to enable the service non-statically.
>>>
>>> What's the problem?
>>> Services are typically hooked up in multi-user.target, sockets in
>>> sockets.target.
>>
>> If I add the service to multi-user.target, the service will initially
>> exit non-zero and systemd regards it failed. Happens because the service
>> was "just started" rather than invoked by socket activation.
>> /lib/systemd/systemd-socket-proxyd will complain that no socket had been
>> passed.
>
> And how is this fixed by enabling it statically?
Because the system '.socket' file automatically starts, and once
something connect to the 'Listen=127.0.0.1:9050' it starts the actual
handler, i.e. the '.service' file. If it happens that way,
systemd-socket-proxyd won't complain, that no socket had been passed -
because the '.socket' file passes the socket.
If the '.service' was automatically started, I think that would be
besides the point of systemd socket activation. As far as I understood
it, the beauty of systemd socket activation is that it only starts the
services once they are needed. Similar to inetd.
(Hopefully I did not mess up terminology. By static systemd unit file I
am referring a systemd unit file without an [Install] section.)
> If your service requires the socket, maybe you should add proper
> dependencies/orderings to the service file.
Well, if I do it like this (simplified):
my-service.service:
#####
[Unit]
After=my-service.socket
Requires=my-service.socket
[Install]
WantedBy=multi-user.target
#####
Then the service auto starts without any error messages. But that's
besides the point. The idea behind the '.socket' file and systemd socket
activation is to only auto start the service when something connects to
'Listen=127.0.0.1:9050'.
Perhaps my misconception is to want to use Debian and to only want to
start the service through systemd socket activation [i.e. through the
'.socket' file]? Debian usually enables and auto starts services after
package installation. Other distributions have different policies on
that. And that's fine. But then '.socket' files would make less sense in
Debian?
More information about the Whonix-devel
mailing list