Bug 90505 - RFE: Singleton Template
Summary: RFE: Singleton Template
Status: RESOLVED WONTFIX
Alias: None
Product: systemd
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: All Linux (All)
: medium normal
Assignee: systemd-bugs
QA Contact: systemd-bugs
URL: http://stackoverflow.com/questions/30...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-18 10:23 UTC by Sah Lee
Modified: 2018-03-09 08:00 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Sah Lee 2015-05-18 10:23:33 UTC
Systemd must provide an option in Unit configuration to indicate a template to be singleton.

There are use cases where a template should have only one instance at a time, and whenever it is instantiated, the existing instance must be stopped first.

My own case is described in this question on Stackoverflow:
http://stackoverflow.com/questions/30208805/systemd-how-to-write-a-singleton-unit-template
Comment 1 Lennart Poettering 2015-05-18 16:21:24 UTC
Hmm? I am not sure I get what you want:

templates and instances are concepts we introduced to allow multiple instances of services, and they only exist for that reason. Before we had them, every unit was a singleton. Hence: if you want a singleton, then simply use a non-template/non-instance unit and all should be good.
Comment 2 Sah Lee 2015-06-08 23:26:37 UTC
Thanks for replying @Lennart .

I am using Systemd to maintain a set of network adaptation scripts, meaning, for instance, to mount samba drives and switch to a certain proxy when I am in office, and to switch to my own proxy (that can bypass the Great Firewall of China) when I am in Starbucks, etc..

To group all the service units, I created a template: `network@.target`, and have several instances such as `network@office.target`, `network@home.target`, `network@starbucks.target`, `network@offline.target`, etc..

Now due to the nature of these targets, there should always be only one instance that is active. But I can't find a way to define this exclusiveness.
Comment 3 Zbigniew Jedrzejewski-Szmek 2018-03-09 08:00:46 UTC
Closing all stale bugs with NEEDINFO. Please open a new bug at https://github.com/systemd/issues if the problem still occurs.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.