On Sun, Feb 13, 2022 at 1:09 PM Wols Lists <antlists@xxxxxxxxxxxxxxx> wrote:
On 13/02/2022 09:54, Mantas Mikulėnas wrote:
> On Sun, Feb 13, 2022 at 2:03 AM Wol <antlists@xxxxxxxxxxxxxxx
> <mailto:antlists@xxxxxxxxxxxxxxx>> wrote:
>
> More fun getting things to work ... :-)
>
> So I've got a service, scarletdme.service, which fires up my db backend
> for running interactively. However, I also need a socket service for
> remote connections.
>
> I've got the xinetd files, but if I'm running systemd, I want to use
> systemd :-)
>
> So I've written scarletdme.socket, and scarletdme@.service, but the
> more
> I read, the more I don't understand ...
>
> Do I enable scarletdme.socket the same as anything else eg "systemctl
> enable scarletdme.socket"? How does it know the difference between
> scarletdme.service and scarletdme@.service? I get the impression I need
> to put something in the .socket file to make it use scarletdme@ rather
> than scarletdme?
>
>
> If it's a 'nowait' socket (which is "[Socket] Accept=yes" in systemd
> terms), then it will use the templated @.service, starting a new
> instance for each "accepted" socket (i.e. instance per connection). See
> oidentd.socket for comparison.
>
> Otherwise (by default) it uses the non-templated service and directly
> gives it the "listening" socket, letting the service itself handle accept().
>
??? Sorry, that's double dutch to me.
Are you telling me that just copying the files into /lib/systemd/system
will enable them? That seems weird to me because it doesn't do it for
normal services afaik. (Or shouldn't I be copying it direct into
/lib/systemd/system? I just don't know ...)
No, I was not talking about any of that. You asked how systemd knows the difference between dme.service and dme@.service.
Sockets (and other units) are "started" and/or "enabled" the same way services are. If you want a service to launch its process right now, you `systemctl start` it. Likewise, if you want a .socket to start listening right now, you `systemctl start` it, and if you want a .timer to start scheduling right now, you `systemctl start` it.
You use `systemctl enable` if you want a unit to be automatically started at boot time – or whatever else its [Install] section says. The "enable" command sets up dependency symlinks from the [Install] section, where you have "WantedBy=sockets.target" or similar. (If there's no [Install] section yet, then `systemctl enable` will do nothing.)
Now whether dme.socket uses dme.service vs dme@.service has absolutely no relationship to any of the above.
Mantas Mikulėnas