[Rdo-list] Question about Restart=always in systemd

Lars Kellogg-Stedman lars at redhat.com
Tue Sep 15 16:37:56 UTC 2015


On Fri, Sep 11, 2015 at 11:32:14AM -0400, Matthew Miller wrote:
> On Fri, Sep 04, 2015 at 11:17:16AM -0400, Matthew Miller wrote:
> > > I'd think that "Restart=always" is a good setting for all services.
> > > What it really brings up is maybe the issue of streamlining the unit
> > > config files.
> > 
> > For several releases, we've had packaging guidelines in Fedora
> > encouraging Restart=on-failure or Restart=on-abnormal:
> > 
> > https://fedoraproject.org/wiki/Packaging:Systemd#Automatic_restarting
> > 
> > We never, however, had an effort to bring existing packages into a
> > consistent state. I'd love for that effort to happen — anyone
> > interesting in helping out?
> 
> And then there were crickets. :)

I didn't see any other traffic on this, so...

How about a mechanism to *generate* unit files using information
specified by the package?  Maybe packages would provide "stub" unit
files that contain only things that differ from standard behavior
(e.g., description, dependencies, environmentfiles, etc), and then the
actual unit file is generated by filling in the missing information.
E.g., for openstack-nova, a package provides the following stub:

  [Service]
  Type=notify
  NotifyAcess=all
  TimeoutStartSec=0
  User=nova

And then you run:

  install-systemd-unit \
    --execstart /usr/bin/nova-api \
    --description "OpenStack Nova API Server" \
    /path/to/stub/units/openstack-nova-template.service \
    /lib/systemd/system/openstack-nova-api.service

And you get:

  [Unit]
  Description=OpenStack Nova API Server
  After=syslog.target network.target

  [Service]
  Type=notify
  NotifyAccess=all
  User=nova
  ExecStart=/usr/bin/nova-api
  Restart=on-failure

  [Install]
  WantedBy=multi-user.target

And for, say, openstack-nova-scheduler:

  install-systemd-unit \
    --execstart /usr/bin/nova-scheduler \
    --description "OpenStack Nova Scheduler Server" \
    /path/to/stub/units/openstack-nova-template.service \
    /lib/systemd/system/openstack-nova-scheduler.service

Or if that's too crazy, just add a check to the fedora-review tool
that ensures unit files have standard settings, such as the Restart=
setting.  The review could flag things like:

- Missing Restart behavior
- Missing Description

Either solution would be reasonably easy to put together.  I like the
first one, because (a) yay automation and because (b) it would allow
for local policy overrides ("I want all my services to run with
Restart=always instead of Restart=on-failure").

An auditing tool could also be used to check all of the *existing*
packages, if that were preferable in addition to or as an alternative
too either of the above.

-- 
Lars Kellogg-Stedman <lars at redhat.com> | larsks @ {freenode,twitter,github}
Cloud Engineering / OpenStack          | http://blog.oddbit.com/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.rdoproject.org/pipermail/dev/attachments/20150915/09de0d60/attachment.sig>


More information about the dev mailing list