Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restarting services - minimize downtime #23127

Closed
danbst opened this issue Feb 24, 2017 · 2 comments
Closed

Restarting services - minimize downtime #23127

danbst opened this issue Feb 24, 2017 · 2 comments

Comments

@danbst
Copy link
Contributor

danbst commented Feb 24, 2017

Issue description

During recent nixos-rebuild switch I got the following log

...
updating GRUB 2 menu...
stopping the following units: -.slice, alsa-store.service, audit.service, ddclient.service, kmod-static-nodes.service, network-addresses-eth0.service, network-link-eth0.service, network-local-commands.service, network-setup.service, nix-daemon.service, nix-daemon.socket, nscd.service, sshd-keygen.service, systemd-modules-load.service, systemd-sysctl.service, systemd-timesyncd.service, systemd-tmpfiles-clean.timer, systemd-tmpfiles-setup-dev.service, systemd-udev-trigger.service, systemd-udevd-control.socket, systemd-udevd-kernel.socket, systemd-udevd.service, systemd-vconsole-setup.service
Failed to stop -.slice: Operation refused, unit -.slice may be requested by dependency only.
See system logs and 'systemctl status -.slice' for details.
<... HERE A PAUSE FOR ONE MINUTE ...>
NOT restarting the following changed units: getty@tty1.service, systemd-journal-flush.service, systemd-random-seed.service, systemd-remount-fs.service, systemd-tmpfiles-setup.service, systemd-update-utmp.service, systemd-user-sessions.service, user@1001.service
activating the configuration...
setting up /etc...
restarting systemd...
reloading the following units: dbus.service, dev-hugepages.mount, dev-mqueue.mount, firewall.service, proc-sys-fs-binfmt_misc.mount, sys-kernel-debug.mount
restarting the following units: dhcpcd.service, sshd.service, systemd-journald.service, systemd-logind.service
starting the following units: alsa-store.service, audit.service, ddclient.service, kmod-static-nodes.service, network-addresses-eth0.service, network-link-eth0.service, network-local-commands.service, network-setup.service, nix-daemon.socket, nscd.service, sshd-keygen.service, systemd-modules-load.service, systemd-sysctl.service, systemd-timesyncd.service, systemd-tmpfiles-clean.timer, systemd-tmpfiles-setup-dev.service, systemd-udev-trigger.service, systemd-udevd-control.socket, systemd-udevd-kernel.socket, systemd-vconsole-setup.service
the following new units were started: systemd-journal-catalog-update.service

Looks like Nixos restarting logic has two separate algorithms:

  1. stop in parallel, then start in parallel
  2. restart in paralell

Why does the first algorithm even exist? In one of my deployments it resulted in nginx downtime for several minutes. (Speaking of nginx, there is #1988)

How can I change the default behavior of a service to second algorithm?

Technical details

  • System: 17.03pre101636.183eeb3
@fpletz
Copy link
Member

fpletz commented Feb 25, 2017

You can set stopIfChanged to false in the systemd service config to get the second behavior.

@danbst
Copy link
Contributor Author

danbst commented Feb 26, 2017

thanks

@danbst danbst closed this as completed Feb 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants