5
0
mirror of git://git.proxmox.com/git/pve-ha-manager.git synced 2025-01-06 17:18:00 +03:00

add restart_on_error option

This commit is contained in:
Dietmar Maurer 2014-12-16 10:58:32 +01:00
parent 378af51891
commit a7238aaa24

View File

@ -127,15 +127,19 @@ my $server_run = sub {
if ($err) {
syslog ('err', "ERROR: $err");
$self->restart_daemon(5);
exit (0);
if (my $wait_time = $self->{restart_on_error}) {
$self->restart_daemon($wait_time);
exit(0);
} else {
exit(-1);
}
}
syslog("info", "server stopped");
};
sub new {
my ($this, $name, $cmdline) = @_;
my ($this, $name, $cmdline, %params) = @_;
die "please run as root\n" if $> != 0;
@ -166,6 +170,15 @@ sub new {
$0 = $name;
foreach my $opt (keys %params) {
my $value = $params{$opt};
if ($opt eq 'restart_on_error') {
$self->{$opt} = $value;
} else {
die "unknown option '$opt'";
}
}
return $self;
}