On Fri, Aug 21, 2015 at 07:48:04AM +1000, Stuart Longland wrote: > Hi all, > > I've got a silly question regarding systemd. > > I'm currently writing a data collection software package which pulls > data from various sources and provides a real-time and historical data > interface for trending and analysis. Basically the data-gathering > guts of a SCADA system. > > The system is built on the Unix philosophy, so each communications > driver and service runs as a separate process, communicating over > AMQP. So far so good. > > I've used the OpenVPN init script as a template for creating my init > scripts, which allows me to not only start and stop all drivers, but > also start or stop an individual driver. e.g. > > /etc/init.d/driver-service start foo > > ... much the same way you can start and stop individual OpenVPN > tunnels this way. > > That works fine on Debian Wheezy, which uses sysvinit. Not so great > with Jessie on systemd. It seems the arguments after 'start' get > discarded somewhere. My only workaround has been to set > _SYSTEMCTL_SKIP_REDIRECT=1 in my environment (a big thank-you to the > people on this list who pointed this out to me), which then bypasses > systemd and permits the bash script to handle it. > > Is there some way for the init script to tell systemd what subservices > are valid or do I have to maintain specialised scripts for systemd?
I've not played with them myself, but I understand that systemd can use "template" services. If you create a service file called "driver-service@.service", then you can use "%i" as a replaceable parameter in the service definition. So you could, for example tell it to execute "MyScript.sh %i" (or maybe look at EnvironmentFile=%i.conf or similar). Finally, the idea is that you symlink "driver-service@.service" to "driver-service@foo.service", "driver-service@bar.service" and so on, and %i is set to "foo", "bar" etc. > > Regards, > -- > Stuart Longland (aka Redhatter, VK4MSL) > > I haven't lost my mind... > ...it's backed up on a tape somewhere. > -- For more information, please reread.
signature.asc
Description: Digital signature