[systemd-devel] How does systemd discover template instances?

Andrei Borzenkov arvidjaar at gmail.com
Wed Oct 14 22:08:27 PDT 2015



Отправлено с iPhone

> 15 окт. 2015 г., в 7:01, Stuart Longland <stuartl at longlandclan.id.au> написал(а):
> 
>> On 15/10/15 13:23, Andrei Borzenkov wrote:
>> 15.10.2015 00:30, Stuart Longland пишет:
>>> Assuming I have a few files distributed in the base package:
>>>    /lib/systemd/system/comms-drivers.service
>>>    /lib/systemd/system/comms-drivers at .service
>>> 
>>> Ordinarily, one would tell systemd about template instances by creating
>>> symbolic links.
>>> 
>>> Suppose however I wanted to not do this, but instead, provide some
>>> automatic discovery mechanism for systemd, so it could run a script that
>>> would tell it what instances exist.
>>> 
>>> Is there a mechanism for doing this in systemd?
>> 
>> I'm not sure if I actually understand the question, but - templates are
>> instantiated on the fly. If template foo at .service exists and it is
>> attempted to start foo at bar.service, systemd will create it internally.
>> It is full fledged unit that is visible in status, can be stopped, is
>> part of dependency resolution etc.
> 
> Okay, that's useful to know.  So in order to start foo at bar.service, I
> don't need to create any files.
> 
> Question is, how does systemd find out about the existence of
> foo at bar.service without a file being present?
> 

Any access to foo at bar.service will cause it to appear (be instanted from template).


> The idea being that the service foo.service acts as a means of
> starting/stopping/querying all instances.  I would guess that
> stopping/restarting/querying, systemd is smart enough to look at what's
> presently running, however what about starting?
> -- 
> Stuart Longland (aka Redhatter, VK4MSL)
> 
> I haven't lost my mind...
>  ...it's backed up on a tape somewhere.
> 


More information about the systemd-devel mailing list