dh_installinit/dh_systemd_start restart-after-upgrade

Michael Biebl biebl at debian.org
Mon Sep 21 13:31:46 BST 2020


Am 21.09.20 um 02:16 schrieb Daniel Black:
> Hi,
> 
> I wrote https://jira.mariadb.org/browse/MDEV-23321 from a former
> experience as a DBA when I stopped a mariadb service, needed to
> upgrade, and needed to do a few other things before starting the
> service again.
> 
> I was rather surprised when a stopped service was auto started after
> an upgrade when it was stopped. I certainly understand the usefulness
> in starting a server on fresh install.

If you disable the service (in addition to stopping it), it should not
be started. This has been the behaviour in Debian for as long as I can
remember.

> I'm wondering has this scenario been considered from a generic
> packaging standpoint? Would I be going against policy to try to do
> this?
> 
> MariaDB (upstream) packages on compat 9 use:
> 
>   dh_systemd_start --restart-after-upgrade
> 
> note: I did fine the compat 11 notice that dh_installsystemd is the
> new way (https://alioth-lists.debian.net/pipermail/pkg-systemd-maintainers/2018-September.txt)
> 
> As I understand it, if dh_systemd_start/dh_installsystemd
> --restart-after-upgrade doesn't consider the previous state an
> implementation would look like:
> 
> preinst install - would save the running states (some variant of
> systemctl --list-units)
> 
> (at some point later) - if there's a state recorded, only start the
> listed service(s).
> 
> So where could states be saved?
> 
> Does any other package that you know of attempt to do this?

I guess what you are looking for is "try-restart".
It seems we only use that though, when used in combination with
--no-start in dh_installsystemd:
https://salsa.debian.org/debian/debhelper/-/blob/master/dh_installsystemd#L420

For a regular restart-after-upgrade, we use a "restart":
https://salsa.debian.org/debian/debhelper/-/blob/master/dh_installsystemd#L423

Maybe it would make sense to use try-restart for "restart" as well,
dunno. We didn't use that in dh_systemd_start, as this was more
entangled with sysvinit, which doesn't support "try-restart".

> Do you know of an existing package that handles the restart of
> multi-instance systemd services?

You might have a look at openvpn. I think they have a master/dummy
openvpn.service which the instanced services bind to (via PartOf).

       PartOf=
           Configures dependencies similar to Requires=, but limited to
stopping and restarting of units. When systemd stops or restarts the
units listed
           here, the action is propagated to this unit. Note that this
is a one-way dependency — changes to this unit do not affect the listed
units.

           When PartOf=b.service is used on a.service, this dependency
will show as ConsistsOf=a.service in property listing of b.service.
ConsistsOf=
           dependency cannot be specified directly.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://alioth-lists.debian.net/pipermail/pkg-systemd-maintainers/attachments/20200921/04a54f59/attachment.sig>


More information about the Pkg-systemd-maintainers mailing list