Re: [systemd-devel] run no more than one of foo@.service at a time

2015-10-06 Thread Johannes Ernst

> On Oct 6, 2015, at 6:19, Lennart Poettering  wrote:
> 
> On Mon, 05.10.15 09:04, Johannes Ernst (johannes.er...@gmail.com) wrote:
> 
>> I have a foo@.service. When started as
>>  systemctl start foo@abc
>> I’d like all other currently active foo@… services to stop, and vice versa. 
>> All of the foo@.services are supposed to be mutually exclusive with each 
>> other.
>> 
>> In foo@.service, I attempted:
>>  Conflicts: foo@.service
>> but that does not seem to do the trick (Starting foo@abc produces 
>> "Dependency Conflicts=foo@abc.service dropped”)
>> 
>> I’d like to avoid having to enumerate foo@abc, foo@def etc. in the Conflicts 
>> section.
> 
> Service templates are really about multi-instantiation, and explicitly
> not about enabling parameterization. That's why we only take a single
> instance identifier as parameter, and not a list of parameters, for
> example.

Good to know the principle here.

> Why wouldn't a nomral suervice suffice for your usecase, with maybe a
> few .d/ dropins to configure things differently?

That’s the kind of thing I will probably do.

Thanks,



Johannes.

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] run no more than one of foo@.service at a time

2015-10-06 Thread Colin Guthrie
Johannes Ernst wrote on 05/10/15 23:53:
> 
>> On Oct 5, 2015, at 14:29, David Timothy Strauss
>> > wrote:
>>
>> If you only want one instance running, why not just create one service
>> and reconfigure/restart it?
>>
> Because the service dependencies are totally different.

If the service dependencies are totally different, why are you using a
templated unit? Surely templated units have to have the same dependences.

Basically in your unit, you are presumably using %i or %I in it in some
capacity.

What David suggested was using a
/etc/systemd/system/foo.service.d/config.conf dropin file to add a
"Environment=MYVAR=newval" line and use $MYVAR in your unit rather than
%i or %I.

This is the same approach but you configure your unit appropriately
rather than using instances.

If you post your unit or provide more details of the kind of thing you
are actually wanting to achieve (rather than the solution you want) then
people may be able to offer other suggestions.

Cheers

Col

-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] run no more than one of foo@.service at a time

2015-10-06 Thread Lennart Poettering
On Mon, 05.10.15 09:04, Johannes Ernst (johannes.er...@gmail.com) wrote:

> I have a foo@.service. When started as
>   systemctl start foo@abc
> I’d like all other currently active foo@… services to stop, and vice versa. 
> All of the foo@.services are supposed to be mutually exclusive with each 
> other.
> 
> In foo@.service, I attempted:
>   Conflicts: foo@.service
> but that does not seem to do the trick (Starting foo@abc produces "Dependency 
> Conflicts=foo@abc.service dropped”)
> 
> I’d like to avoid having to enumerate foo@abc, foo@def etc. in the Conflicts 
> section.

Service templates are really about multi-instantiation, and explicitly
not about enabling parameterization. That's why we only take a single
instance identifier as parameter, and not a list of parameters, for
example.

Why wouldn't a nomral suervice suffice for your usecase, with maybe a
few .d/ dropins to configure things differently?

Lennart

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


Re: [systemd-devel] run no more than one of foo@.service at a time

2015-10-05 Thread David Timothy Strauss
If you only want one instance running, why not just create one service and
reconfigure/restart it?

On Mon, Oct 5, 2015, 09:04 Johannes Ernst  wrote:

> I have a foo@.service. When started as
> systemctl start foo@abc
> I’d like all other currently active foo@… services to stop, and vice
> versa. All of the foo@.services are supposed to be mutually exclusive
> with each other.
>
> In foo@.service, I attempted:
> Conflicts: foo@.service
> but that does not seem to do the trick (Starting foo@abc produces
> "Dependency Conflicts=foo@abc.service dropped”)
>
> I’d like to avoid having to enumerate foo@abc, foo@def etc. in the
> Conflicts section.
>
> Ideas?
>
> Thanks,
>
>
>
> Johannes.
>
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] run no more than one of foo@.service at a time

2015-10-05 Thread Johannes Ernst

> On Oct 5, 2015, at 14:29, David Timothy Strauss  
> wrote:
> 
> If you only want one instance running, why not just create one service and 
> reconfigure/restart it?
> 
Because the service dependencies are totally different.

> 
> On Mon, Oct 5, 2015, 09:04 Johannes Ernst  > wrote:
> I have a foo@.service. When started as
> systemctl start foo@abc
> I’d like all other currently active foo@… services to stop, and vice versa. 
> All of the foo@.services are supposed to be mutually exclusive with each 
> other.
> 
> In foo@.service, I attempted:
> Conflicts: foo@.service
> but that does not seem to do the trick (Starting foo@abc produces "Dependency 
> Conflicts=foo@abc.service dropped”)
> 
> I’d like to avoid having to enumerate foo@abc, foo@def etc. in the Conflicts 
> section.
> 
> Ideas?
> 
> Thanks,
> 
> 
> 
> Johannes.
> 
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org 
> 
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel 
> 

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] run no more than one of foo@.service at a time

2015-10-05 Thread Johannes Ernst
I have a foo@.service. When started as
systemctl start foo@abc
I’d like all other currently active foo@… services to stop, and vice versa. All 
of the foo@.services are supposed to be mutually exclusive with each other.

In foo@.service, I attempted:
Conflicts: foo@.service
but that does not seem to do the trick (Starting foo@abc produces "Dependency 
Conflicts=foo@abc.service dropped”)

I’d like to avoid having to enumerate foo@abc, foo@def etc. in the Conflicts 
section.

Ideas?

Thanks,



Johannes.

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel