switch-to-configuration: Support services activated by multiple sockets
This commit is contained in:
parent
b4a1893cdd
commit
06cbe62537
@ -146,18 +146,29 @@ while (my ($unit, $state) = each %{$activePrev}) {
|
|||||||
{
|
{
|
||||||
push @unitsToSkip, $unit;
|
push @unitsToSkip, $unit;
|
||||||
} else {
|
} else {
|
||||||
# If this unit has a corresponding socket unit,
|
# If this unit is socket-activated, then stop the
|
||||||
# then stop the socket unit as well, and restart
|
# socket unit(s) as well, and restart the
|
||||||
# the socket instead of the service.
|
# socket(s) instead of the service.
|
||||||
if ($unit =~ /\.service$/ && defined $activePrev->{"$baseName.socket"}) {
|
my $socketActivated = 0;
|
||||||
push @unitsToStop, "$baseName.socket";
|
if ($unit =~ /\.service$/) {
|
||||||
write_file($restartListFile, { append => 1 }, "$baseName.socket\n");
|
my @sockets = split / /, ($unitInfo->{Sockets} // "");
|
||||||
|
if (scalar @sockets == 0) {
|
||||||
|
@sockets = ("$baseName.socket");
|
||||||
|
}
|
||||||
|
foreach my $socket (@sockets) {
|
||||||
|
if (defined $activePrev->{$socket}) {
|
||||||
|
push @unitsToStop, $socket;
|
||||||
|
write_file($restartListFile, { append => 1 }, "$socket\n");
|
||||||
|
$socketActivated = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Record that this unit needs to be started below. We
|
# Otherwise, record that this unit needs to be
|
||||||
# write this to a file to ensure that the service gets
|
# started below. We write this to a file to
|
||||||
# restarted if we're interrupted.
|
# ensure that the service gets restarted if we're
|
||||||
else {
|
# interrupted.
|
||||||
|
if (!$socketActivated) {
|
||||||
write_file($restartListFile, { append => 1 }, "$unit\n");
|
write_file($restartListFile, { append => 1 }, "$unit\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user