]> git.proxmox.com Git - pve-ha-manager.git/blob - src/PVE/Service/pve_ha_lrm.pm
fix includes from services
[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 use Data::Dumper;
8
9 use PVE::HA::Env;
10 use PVE::HA::Env::PVE2;
11 use PVE::HA::LRM;
12
13 use base qw(PVE::Daemon);
14
15 my $cmdline = [$0, @ARGV];
16
17 my %daemon_options = (stop_wait_time => 180);
18
19 my $daemon = __PACKAGE__->new('pve-ha-lrm', $cmdline, %daemon_options);
20
21 sub run {
22 my ($self) = @_;
23
24 $self->{haenv} = PVE::HA::Env->new('PVE::HA::Env::PVE2', $self->{nodename});
25
26 $self->{lrm} = PVE::HA::LRM->new($self->{haenv});
27
28 for (;;) {
29 $self->{haenv}->loop_start_hook();
30
31 my $repeat = $self->{lrm}->do_one_iteration();
32
33 $self->{haenv}->loop_end_hook();
34
35 last if !$repeat;
36 }
37 }
38
39 sub shutdown {
40 my ($self) = @_;
41
42 $self->{lrm}->shutdown_request();
43 }
44
45 $daemon->register_start_command();
46 $daemon->register_stop_command();
47 $daemon->register_status_command();
48
49 our $cmddef = {
50 start => [ __PACKAGE__, 'start', []],
51 stop => [ __PACKAGE__, 'stop', []],
52 status => [ __PACKAGE__, 'status', [], undef, sub { print shift . "\n";} ],
53 };
54
55 1;
56
57 __END__
58
59 =head1 NAME
60
61 pve-ha-lrm - PVE Local HA Ressource Manager Daemon
62
63 =head1 SYNOPSIS
64
65 =include synopsis
66
67 =head1 DESCRIPTION
68
69 This is the Local HA Ressource Manager.
70
71 =include pve_copyright