Skip to content

Commit 89806e9

Browse files
fpletzlheckemann
authored andcommitted
nixos/switch-to-configuration: restart changed socket units
Previously, socket units wouldn't be restarted if they were changed. To restart the socket, the service the socket is attached to needs to be stopped first before the socket can be restarted.
1 parent e3e3bd6 commit 89806e9

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

nixos/modules/system/activation/switch-to-configuration.pl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,17 @@ sub fingerprintUnit {
214214
# Reload the changed mount unit to force a remount.
215215
$unitsToReload{$unit} = 1;
216216
recordUnit($reloadListFile, $unit);
217-
} elsif ($unit =~ /\.socket$/ || $unit =~ /\.path$/ || $unit =~ /\.slice$/) {
217+
} elsif ($unit =~ /\.socket$/) {
218+
my $unitInfo = parseUnit($newUnitFile);
219+
# If a socket unit has been changed, the corresponding
220+
# service unit has to be stopped before the socket can
221+
# be restarted. The service will be started again on demand.
222+
my $serviceUnit = $unitInfo->{'Unit'} // "$baseName.service";
223+
$unitsToStop{$serviceUnit} = 1;
224+
$unitsToStop{$unit} = 1;
225+
$unitsToStart{$unit} = 1;
226+
recordUnit($startListFile, $unit);
227+
} elsif ($unit =~ /\.path$/ || $unit =~ /\.slice$/) {
218228
# FIXME: do something?
219229
} else {
220230
my $unitInfo = parseUnit($newUnitFile);

0 commit comments

Comments
 (0)