On Thu, 15 Oct 2015, Stuart Longland wrote:
Assuming I have a few files distributed in the base package:
/lib/systemd/system/comms-drivers.service
/lib/systemd/system/comms-drivers@.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?
Hi Stuart,
One approach you might want to consider is using a systemd generator [1]
to create the instance symlinks automatically at boot, e.g.:
ARGV[1]/comms-driver@some-instance.service
-> /lib/systemd/system/comms-drivers@.service
The ARGV[1] argument passed to your generator is likely to be
"/run/systemd/generator".
Your generator can use any mechanism it likes to decide which instances
should be created. Note, however, the generator is run very early on in
boot (and whenever systemd's configuration is reloaded), so it should be
lightweight and not need any other system services to be operational.
If you have particular instances you want started at boot, you can link
them in to the appropriate target's .wants directory, e.g.:
ARGV[1]/multi-user.target.wants/comms-driver@some-instance.service
-> /lib/systemd/system/comms-drivers@.service
Hope this is of assistance.
Regards,
Michael
[1] http://www.freedesktop.org/software/systemd/man/systemd.generator.html
_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel