]> git.proxmox.com Git - pve-ha-manager.git/blob - src/PVE/Service/pve_ha_lrm.pm
bump version to 4.0.5
[pve-ha-manager.git] / src / PVE / Service / pve_ha_lrm.pm
1 package PVE::Service::pve_ha_lrm;
2
3 use strict;
4 use warnings;
5
6 use PVE::Daemon;
7
8 use PVE::HA::Env;
9 use PVE::HA::Env::PVE2;
10 use PVE::HA::LRM;
11
12 use base qw(PVE::Daemon);
13
14 my $cmdline = [$0, @ARGV];
15
16 my %daemon_options = (stop_wait_time => 60*60);
17
18 my $daemon = __PACKAGE__->new('pve-ha-lrm', $cmdline, %daemon_options);
19
20 sub run {
21 my ($self) = @_;
22
23 $self->{haenv} = PVE::HA::Env->new('PVE::HA::Env::PVE2', $self->{nodename});
24
25 $self->{lrm} = PVE::HA::LRM->new($self->{haenv});
26
27 for (;;) {
28 last if !$self->{lrm}->do_one_iteration();
29 }
30 }
31
32 sub shutdown {
33 my ($self) = @_;
34
35 $self->{lrm}->shutdown_request();
36 }
37
38 $daemon->register_start_command();
39 $daemon->register_stop_command();
40 $daemon->register_status_command();
41
42 our $cmddef = {
43 start => [ __PACKAGE__, 'start', []],
44 stop => [ __PACKAGE__, 'stop', []],
45 status => [ __PACKAGE__, 'status', [], undef, sub { print shift . "\n";} ],
46 };
47
48 1;