]> git.proxmox.com Git - pve-ha-manager.git/blobdiff - src/pve-ha-lrm
LRM: release lock and close watchdog if no service configured for >10min
[pve-ha-manager.git] / src / pve-ha-lrm
index b5fe29cd33152f5b6bc74a70a74ec4ae6f3938b5..52c1e0b7f8a46181a2039ec1efbfa174635a3b05 100755 (executable)
@@ -2,16 +2,11 @@
 
 use strict;
 use warnings;
-use PVE::SafeSyslog;
-use PVE::Daemon;
-use Data::Dumper;
-use PVE::RPCEnvironment;
 
-use PVE::HA::Env;
-use PVE::HA::Env::PVE2;
-use PVE::HA::LRM;
+use PVE::Service::pve_ha_lrm;
 
-use base qw(PVE::Daemon);
+use PVE::RPCEnvironment;
+use PVE::SafeSyslog;
 
 $SIG{'__WARN__'} = sub {
     my $err = $@;
@@ -22,70 +17,14 @@ $SIG{'__WARN__'} = sub {
     $@ = $err;
 };
 
-my $cmdline = [$0, @ARGV];
-
-my %daemon_options = (stop_wait_time => 180);
-
-my $daemon = __PACKAGE__->new('pve-ha-lrm', $cmdline, %daemon_options);
-
-my $rpcenv = PVE::RPCEnvironment->init('cli');
-
-$rpcenv->init_request();
-$rpcenv->set_language($ENV{LANG});
-$rpcenv->set_user('root@pam');
-
-sub run {
-    my ($self) = @_;
-
-    $self->{haenv} = PVE::HA::Env->new('PVE::HA::Env::PVE2', $self->{nodename});
-
-    $self->{lrm} = PVE::HA::LRM->new($self->{haenv});
-
-    for (;;) {
-       $self->{haenv}->loop_start_hook();
-
-       my $repeat = $self->{lrm}->do_one_iteration();
+my $prepare = sub {
 
-       $self->{haenv}->loop_end_hook();
+    my $rpcenv = PVE::RPCEnvironment->init('ha');
 
-       last if !$repeat;
-    }
-}
+    $rpcenv->init_request();
+    $rpcenv->set_language($ENV{LANG});
+    $rpcenv->set_user('root@pam');
 
-sub shutdown {
-    my ($self) = @_;
-
-    $self->{lrm}->shutdown_request();
-}
-
-$daemon->register_start_command();
-$daemon->register_stop_command();
-$daemon->register_status_command();
-
-my $cmddef = {
-    start => [ __PACKAGE__, 'start', []],
-    stop => [ __PACKAGE__, 'stop', []],
-    status => [ __PACKAGE__, 'status', [], undef, sub { print shift . "\n";} ],
 };
 
-my $cmd = shift;
-
-PVE::CLIHandler::handle_cmd($cmddef, $0, $cmd, \@ARGV, undef, $0);
-
-exit (0);
-
-__END__
-
-=head1 NAME
-                                          
-pve-ha-lrm - PVE Local HA Ressource Manager Daemon
-
-=head1 SYNOPSIS
-
-=include synopsis
-
-=head1 DESCRIPTION
-
-This is the Local HA Ressource Manager.
-
-=include pve_copyright
+PVE::Service::pve_ha_lrm->run_cli_handler(prepare => $prepare);