1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-09-11 15:08:33 +01:00

switch-to-configuration: fix restart of socket activated services

This fixes two bugs:

* When socket activation is detected, the service itself is added to stop-start list instead of its sockets.
* When service is marked to restart instead of stop (`StopIfChanged = no`) we don't need to restart sockets.
This commit is contained in:
Nikolay Amiantov 2016-09-30 17:05:31 +03:00
parent ff0b8b2225
commit d37458ad06

View file

@ -212,6 +212,12 @@ while (my ($unit, $state) = each %{$activePrev}) {
} }
elsif (!boolIsTrue($unitInfo->{'X-RestartIfChanged'} // "yes") || boolIsTrue($unitInfo->{'RefuseManualStop'} // "no") ) { elsif (!boolIsTrue($unitInfo->{'X-RestartIfChanged'} // "yes") || boolIsTrue($unitInfo->{'RefuseManualStop'} // "no") ) {
$unitsToSkip{$unit} = 1; $unitsToSkip{$unit} = 1;
} else {
if (!boolIsTrue($unitInfo->{'X-StopIfChanged'} // "yes")) {
# This unit should be restarted instead of
# stopped and started.
$unitsToRestart{$unit} = 1;
recordUnit($restartListFile, $unit);
} else { } else {
# If this unit is socket-activated, then stop the # If this unit is socket-activated, then stop the
# socket unit(s) as well, and restart the # socket unit(s) as well, and restart the
@ -224,23 +230,14 @@ while (my ($unit, $state) = each %{$activePrev}) {
} }
foreach my $socket (@sockets) { foreach my $socket (@sockets) {
if (defined $activePrev->{$socket}) { if (defined $activePrev->{$socket}) {
$unitsToStop{$unit} = 1; $unitsToStop{$socket} = 1;
$unitsToStart{$unit} = 1; $unitsToStart{$socket} = 1;
recordUnit($startListFile, $socket); recordUnit($startListFile, $socket);
$socketActivated = 1; $socketActivated = 1;
} }
} }
} }
if (!boolIsTrue($unitInfo->{'X-StopIfChanged'} // "yes")) {
# This unit should be restarted instead of
# stopped and started.
$unitsToRestart{$unit} = 1;
recordUnit($restartListFile, $unit);
} else {
# If the unit is not socket-activated, record # If the unit is not socket-activated, record
# that this unit needs to be started below. # that this unit needs to be started below.
# We write this to a file to ensure that the # We write this to a file to ensure that the
@ -251,7 +248,6 @@ while (my ($unit, $state) = each %{$activePrev}) {
} }
$unitsToStop{$unit} = 1; $unitsToStop{$unit} = 1;
} }
} }
} }