Re: [systemd-devel] Service activation

2022-02-13 Thread Wol

On 13/02/2022 16:42, Michael Biebl wrote:

So the answer to that is nice and simple,
"systemctl enable/start scarletdme.socket"

no, you start a socket by "systemctl start". You enable a socket,
service, unit,... via "systemctl enable"

enable and start are different concepts.


Yes. I know. But.

Bearing in mind my knowledge of systemd was pretty much NIL a week or 
two ago, apart from following recipes for gentoo ... (which is not 
particularly systemd-friendly ...)


I've learnt a heck of a lot very quickly :-) but as I see it "start" 
starts the service *now*, "enable" starts the service *at boot*.



Now what I don't want is for scarletdme.socket to invoke
scarletdme.service. How do I tell it that it is supposed to invoke
scarletdme@.service? Or have I messed up naming conventions? Or what the
hell is the proper way to do it?



Please read again what Mantas wrote. He explained all that rather nicely.


Just like a manual ... now I've gone back to it, (now I've found a 
*longer* explanation elsewhere,) it makes sense. "nowait", "template", 
all that stuff, I didn't understand that ...


Sorry, but when you're explaining things, you need to go into much more 
detail than you may be comfortable with. Otherwise you're just 
explaining terms the questioner doesn't understand, using other terms 
they don't understand ... :-) Them as can't do, teach ... because them 
as can do often can't teach :-)


Anyway, thanks a lot. It has helped, it made it much easier for me to 
"know what I didn't know" and find what I needed.


Cheers,
Wol


Re: [systemd-devel] Service activation

2022-02-13 Thread Michael Biebl
Am So., 13. Feb. 2022 um 17:01 Uhr schrieb Wols Lists
:
>
> On 13/02/2022 15:46, Mantas Mikulėnas wrote:
> > On Sun, Feb 13, 2022 at 1:09 PM Wols Lists  > > wrote:
> >
> > On 13/02/2022 09:54, Mantas Mikulėnas wrote:
> >  > On Sun, Feb 13, 2022 at 2:03 AM Wol  > 
> >  >  > >> 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.
>
> Let's rewind a moment. That was my SECOND question. That's one of the
> reasons I got confused, because my FIRST question WAS "how do I start
> scarletdme.socket?"
>
> So the answer to that is nice and simple,
> "systemctl enable/start scarletdme.socket"

no, you start a socket by "systemctl start". You enable a socket,
service, unit,... via "systemctl enable"

enable and start are different concepts.

> Now what I don't want is for scarletdme.socket to invoke
> scarletdme.service. How do I tell it that it is supposed to invoke
> scarletdme@.service? Or have I messed up naming conventions? Or what the
> hell is the proper way to do it?

Please read again what Mantas wrote. He explained all that rather nicely.


Re: [systemd-devel] Service activation

2022-02-13 Thread Wols Lists

On 13/02/2022 15:46, Mantas Mikulėnas wrote:
On Sun, Feb 13, 2022 at 1:09 PM Wols Lists > wrote:


On 13/02/2022 09:54, Mantas Mikulėnas wrote:
 > On Sun, Feb 13, 2022 at 2:03 AM Wol mailto:antli...@youngman.org.uk>
 > >> 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.


Let's rewind a moment. That was my SECOND question. That's one of the 
reasons I got confused, because my FIRST question WAS "how do I start 
scarletdme.socket?"


So the answer to that is nice and simple,
"systemctl enable/start scarletdme.socket"

Now what I don't want is for scarletdme.socket to invoke 
scarletdme.service. How do I tell it that it is supposed to invoke 
scarletdme@.service? Or have I messed up naming conventions? Or what the 
hell is the proper way to do it?


Cheers,
Wol



Re: [systemd-devel] Service activation

2022-02-13 Thread Mantas Mikulėnas
On Sun, Feb 13, 2022 at 1:09 PM Wols Lists  wrote:

> On 13/02/2022 09:54, Mantas Mikulėnas wrote:
> > On Sun, Feb 13, 2022 at 2:03 AM Wol  > > 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


Re: [systemd-devel] Service activation

2022-02-13 Thread Wols Lists

On 13/02/2022 09:54, Mantas Mikulėnas wrote:
On Sun, Feb 13, 2022 at 2:03 AM Wol > 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 ...)


So I do systemctl status and get this - I'm surprised I got anything!

thewolery /home/anthony/gitstuff # systemctl status scarletdme.socket
○ scarletdme.socket - ScarletDME Per-Connection Server
 Loaded: loaded (/lib/systemd/system/scarletdme.socket; disabled; 
vendor preset: disabled)

 Active: inactive (dead)
 Listen: [::]:4242 (Stream)
   Accepted: 0; Connected: 0;
thewolery /home/anthony/gitstuff #

Does that mean when I connect it will fire off the scarletdme@.service? 
Or does all the disabled stuff means systemd has found it but is 
ignoring it?


Sorry, I know all this is supposed to be "simple", and when I've done it 
once or twice it will be, but at the moment I just don't have a clue.



And once I've got all that sorted, I'm betting I'm going to have grief
getting it to work properly, so while it's not much to do with systemd,
is there any way I can get systemd to log all traffic back and forth so
I can debug it?


No, the traffic doesn't even go through systemd in the first place.


Cheers,
Thanks


Re: [systemd-devel] Service activation

2022-02-13 Thread Mantas Mikulėnas
On Sun, Feb 13, 2022 at 2:03 AM Wol  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().


>
>
> And once I've got all that sorted, I'm betting I'm going to have grief
> getting it to work properly, so while it's not much to do with systemd,
> is there any way I can get systemd to log all traffic back and forth so
> I can debug it?
>

No, the traffic doesn't even go through systemd in the first place.

-- 
Mantas Mikulėnas