-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
nixos/switch-to-configuration: Document and test handling of socket-activated services #161838
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -307,6 +307,7 @@ sub handleModifiedUnit { | |
| # seem to get applied on daemon-reload. | ||
| } elsif ($unit =~ /\.mount$/) { | ||
| # Reload the changed mount unit to force a remount. | ||
| # FIXME: only reload when Options= changed, restart otherwise | ||
| $unitsToReload->{$unit} = 1; | ||
| recordUnit($reloadListFile, $unit); | ||
| } elsif ($unit =~ /\.socket$/) { | ||
|
|
@@ -339,21 +340,23 @@ sub handleModifiedUnit { | |
| # If this unit is socket-activated, then stop the | ||
| # socket unit(s) as well, and restart the | ||
| # socket(s) instead of the service. | ||
| my $socketActivated = 0; | ||
| my $socket_activated = 0; | ||
|
||
| if ($unit =~ /\.service$/) { | ||
| my @sockets = split(/ /, join(" ", @{$unitInfo{Service}{Sockets} // []})); | ||
| if (scalar @sockets == 0) { | ||
| @sockets = ("$baseName.socket"); | ||
| } | ||
| foreach my $socket (@sockets) { | ||
| if (defined $activePrev->{$socket}) { | ||
| # We can now be sure this is a socket-activate unit | ||
|
|
||
| $unitsToStop->{$socket} = 1; | ||
| # Only restart sockets that actually | ||
| # exist in new configuration: | ||
| if (-e "$out/etc/systemd/system/$socket") { | ||
| $unitsToStart->{$socket} = 1; | ||
| recordUnit($startListFile, $socket); | ||
| $socketActivated = 1; | ||
| $socket_activated = 1; | ||
| } | ||
| # Remove from units to reload so we don't restart and reload | ||
| if ($unitsToReload->{$unit}) { | ||
|
|
@@ -368,7 +371,7 @@ sub handleModifiedUnit { | |
| # that this unit needs to be started below. | ||
| # We write this to a file to ensure that the | ||
| # service gets restarted if we're interrupted. | ||
| if (!$socketActivated) { | ||
| if (!$socket_activated) { | ||
| $unitsToStart->{$unit} = 1; | ||
| recordUnit($startListFile, $unit); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.