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

Stuart Longland stuartl at longlandclan.id.au
Wed Oct 14 14:30:35 PDT 2015


Hi all,

First up, I'm rather new to systemd, having been more or less forced
into it by the decisions of the Ubuntu and Debian projects, which have
both gone that way.

(I know the default can be changed, but upstream have chosen this init
system, so I as a software developer must learn to use it.)

I have a SysV init script which I based on the Debian init script for
OpenVPN.  The service I'm starting up is a collection of device drivers
for a data acquisition system.  (Think: SCADA-style application.)

These drivers run as daemon processes in userspace, and communicate with
devices out in the field by various means (we've got drivers that talk
Modbus and EDMI, we're planning a BACNet driver, etc) and they talk with
the rest of the system over AMQP (RabbitMQ).

The drivers can be written in any language (most are in Python, some may
be done in C++), and may not necessarily take the same command line
arguments.  I'd like to be able to write a set of systemd unit files
that can either selectively, or all together, bring the driver instances
up and down.

The existing script permits this, and under Debian Wheezy, works well.
Under Jessie with systemd however, the systemd wrappers get in the way
and we lose the ability to control individual instances.  I also feel
there are some features of systemd which would be useful (auto-restart
on crash for example).

For that reason, I'm looking at how to write some unit files to achieve
this aim.

I feel I can probably achieve most of this with some simple wrapper
scripts that make the drivers all react the same (in the eyes of
systemd), which brings me to the problem of instances.  (In fact, I can
probably use my existing init script.)

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?
-- 
Stuart Longland (aka Redhatter, VK4MSL)

I haven't lost my mind...
  ...it's backed up on a tape somewhere.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20151015/87f0bd1c/attachment.sig>


More information about the systemd-devel mailing list