nixos-container: support restarts
This commit is contained in:
parent
6c064e6b1f
commit
b95a24fdf1
1 changed files with 15 additions and 2 deletions
|
@ -242,11 +242,21 @@ sub terminateContainer {
|
|||
while ( kill 0, $leader ) { Time::HiRes::sleep(0.1) }
|
||||
}
|
||||
|
||||
sub startContainer {
|
||||
system("systemctl", "start", "container\@$containerName") == 0
|
||||
or die "$0: failed to start container\n";
|
||||
}
|
||||
|
||||
sub stopContainer {
|
||||
system("systemctl", "stop", "container\@$containerName") == 0
|
||||
or die "$0: failed to stop container\n";
|
||||
}
|
||||
|
||||
sub restartContainer {
|
||||
stopContainer;
|
||||
startContainer;
|
||||
}
|
||||
|
||||
# Run a command in the container.
|
||||
sub runInContainer {
|
||||
my @args = @_;
|
||||
|
@ -285,9 +295,12 @@ if ($action eq "destroy") {
|
|||
unlink($confFile) or die;
|
||||
}
|
||||
|
||||
elsif ($action eq "restart") {
|
||||
restartContainer;
|
||||
}
|
||||
|
||||
elsif ($action eq "start") {
|
||||
system("systemctl", "start", "container\@$containerName") == 0
|
||||
or die "$0: failed to start container\n";
|
||||
startContainer;
|
||||
}
|
||||
|
||||
elsif ($action eq "stop") {
|
||||
|
|
Loading…
Reference in a new issue