Re: [systemd-devel] Running a set of group isolated from other services?

2017-04-29 Thread Benno Fünfstück
Great, thanks!

Lennart Poettering  schrieb am Sa., 29. Apr. 2017,
19:32:

> On Wed, 26.04.17 11:08, Benno Fünfstück (benno.fuenfstu...@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@.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
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Running a set of group isolated from other services?

2017-04-29 Thread Lennart Poettering
On Wed, 26.04.17 11:08, Benno Fünfstück (benno.fuenfstu...@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@.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
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Running a set of group isolated from other services?

2017-04-29 Thread Lennart Poettering
On Wed, 26.04.17 11:05, Benno Fünfstück (benno.fuenfstu...@gmail.com) wrote:

> Hi,
> 
> 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

You can share a common environment file between them and use EnvironmentFile=-

> * be able to stop all the services in the group and wait for proper
>   shutdown

Usually you'd create a target unit for that and use PartOf=.

> * (would be nice) load services for the group from a different directory
> than the default one

This is not supported. ATM you cannot extend the unit file search path
locally. It's built into the binary. (Well, to be entirely honest you
can override it with an env var, but it's hard to do for PID 1 and
mostly relevant for debugging)

> * (would be nice) be able to add transient services to the group with
> systemd-run

if you set up such a target unit it doesn't matter whether the
services that are linked to it are transient or persistent.

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Running a set of group isolated from other services?

2017-04-26 Thread Benno Fünfstück
Benno Fünfstück  schrieb am Mi., 26. Apr. 2017
um 13:05 Uhr:

> Hi,
>
> 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)
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Running a set of group isolated from other services?

2017-04-26 Thread Benno Fünfstück
Hi,

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
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel