[systemd-devel] Running a set of group isolated from other services?
Lennart Poettering
lennart at poettering.net
Sat Apr 29 17:31:47 UTC 2017
On Wed, 26.04.17 11:08, Benno Fünfstück (benno.fuenfstueck at gmail.com) wrote:
> > I have the problem that I want to run a set of services that are isolated
> > from the other services. In particular, I'd like to:
> >
> > * share some environment variables between these services, that aren't
> > available for services outside the group
> > * be able to stop all the services in the group and wait for proper
> > shutdown
> > * (would be nice) load services for the group from a different directory
> > than the default one
> > * (would be nice) be able to add transient services to the group with
> > systemd-run
> >
> > Is such a thing possible with systemd? If not, is it feasible to implement
> > something like this (even if it doesn't match exactly what I want)?
> >
> > Regards,
> > Benno
> >
>
> Just to add if that wasn't clear: I'd like to run this group for multiple
> different sets of environment variables, and be able to "start" the group
> for some assignment of environment variables (these variables will not
> change during the lifetime of the group though)
If you want multiple instantation you can use systemd's instance
logic. i.e. you could have:
mygroup at .target
This target unit could then have Wants= deps on your various services,
always passing along the instance identifier:
[Unit]
Wants=myservice1@%i.service myservice2@%i.service
Then, insce the service units you'd add a PartsOf= dep back:
[Unit]
PartOf=mygroup@%i.target
And then pull in the environment file based on the instance:
[Service]
EnvironmentFile=/path/to/my/env-file-%i.conf
I hope that makes sense,
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list