Bug 43818

Summary: RFE: systemd needs a method to dynamically specify a oneshot service
Product: systemd Reporter: Neil Horman <nhorman>
Component: generalAssignee: Lennart Poettering <lennart>
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: medium CC: mgorny
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Neil Horman 2011-12-14 03:56:02 UTC
Several users have traditionally expected the ability to configure irqbalance to run as a oneshot service (i.e. to execute, do some work, and stop).  This has traditionally been specified as an environmental option or command line switch, but systemd offers no such support.  That it to say, while the unit file can be written to specify a oneshot mode of operation, it must be statically declared.  I'd like to be able to specify the unit Type at the time the unit is started
Comment 1 Michał Górny 2011-12-14 06:06:41 UTC
As I have expressed myself before, I don't think that's a good idea. Services should be simpler and more predictable. Using an EnvironmentFile to configure anything service-specific is a bad idea itself, and making Type of service configured through it is even worse.

IMO irqbalance should either provide two separate units for users to choose from, or just plain daemon service file. Adding additional service file in the future wouldn't cause problems; while introducing invalid files right now will make it harder to fix them in the future -- because users will start relying on them.
Comment 2 Neil Horman 2011-12-14 07:03:56 UTC
Users have relied on --oneshot in irqbalance for years, without issue.  The way things "should" be isn't relevant when people have been using a feature effectively without issue.  Nobody expects to have two separate services to start when they've been expecting an environmental config option.
Comment 3 Michał Górny 2011-12-14 07:11:19 UTC
(In reply to comment #2)
> Users have relied on --oneshot in irqbalance for years, without issue.  The way
> things "should" be isn't relevant when people have been using a feature
> effectively without issue.  Nobody expects to have two separate services to
> start when they've been expecting an environmental config option.

systemd users aren't expecting environmental config options. systemd users expect that services should be able to handle their configs without random convoluted hacks.

And systemd users expect multiple separate services. This is how things work. You can use sshd.service to run sshd as a daemon, or sshd.socket to run it on inetd-like basis. Noone expects random /etc/foobarbaz/sshd.magicaloptions with PUT_SOME_RANDOM_STRING_HERE_TO_ENABLE_INETD=and-also-a-few-other-hacks-to-change-service-type.
Comment 4 Neil Horman 2011-12-14 07:23:02 UTC
Its not you're world to control.  There are far more than just systemd users out there, and older, more established init systems have all worked with the existing configuration method.  The fact that you dont' want systemd to work that way doesn't make the old method wrong.
Comment 5 Michał Górny 2011-12-14 07:48:36 UTC
(In reply to comment #4)
> Its not you're world to control.  There are far more than just systemd users
> out there, and older, more established init systems have all worked with the
> existing configuration method.  The fact that you dont' want systemd to work
> that way doesn't make the old method wrong.

And how are non-systemd users related to systemd unit files? Are you suggesting that systemd should be changed to match old rc systems just because things were like that in the past?
Comment 6 Neil Horman 2011-12-14 08:15:07 UTC
No, I'm suggesting that systemd make a very minor concession to provide a modicum of compatibility to the way systems services have operated up until this point.  I would have thought that would have been clear in this bug description.
Comment 7 Zbigniew Jedrzejewski-Szmek 2013-07-16 02:53:04 UTC
You can always drop a snippet into /run/systemd/system/<service>.d/type.conf with something like

[Service]
Type=oneshot

and whatever other adjustments are needed. But like Michał said, it's not a very good idea, it's very specific and doesn't really work in general, since most servcies require different options to start in "oneshot" mode. Once you have different Type, and different options, it's actually better to have two unit files.

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.