]> git.proxmox.com Git - pve-ha-manager.git/blame - src/PVE/Service/pve_ha_crm.pm
clean up 'Data::Dumper' usage tree wide
[pve-ha-manager.git] / src / PVE / Service / pve_ha_crm.pm
CommitLineData
a802c337
TL
1package PVE::Service::pve_ha_crm;
2
3use strict;
4use warnings;
5
a802c337 6use PVE::Daemon;
a802c337
TL
7
8use PVE::HA::Env;
9use PVE::HA::Env::PVE2;
10use PVE::HA::CRM;
11
12use base qw(PVE::Daemon);
13
a802c337
TL
14my $cmdline = [$0, @ARGV];
15
16my %daemon_options = (stop_wait_time => 60);
17
18my $daemon = __PACKAGE__->new('pve-ha-crm', $cmdline, %daemon_options);
19
20sub run {
21 my ($self) = @_;
22
23 $self->{haenv} = PVE::HA::Env->new('PVE::HA::Env::PVE2', $self->{nodename});
24
25 $self->{crm} = PVE::HA::CRM->new($self->{haenv});
26
27 for (;;) {
28 $self->{haenv}->loop_start_hook();
29
30 my $repeat = $self->{crm}->do_one_iteration();
31
32 $self->{haenv}->loop_end_hook();
33
34 last if !$repeat;
35 }
36}
37
38sub shutdown {
39 my ($self) = @_;
40
41 $self->{crm}->shutdown_request();
42}
43
44$daemon->register_start_command();
45$daemon->register_stop_command();
46$daemon->register_status_command();
47
48our $cmddef = {
49 start => [ __PACKAGE__, 'start', []],
50 stop => [ __PACKAGE__, 'stop', []],
51 status => [ __PACKAGE__, 'status', [], undef, sub { print shift . "\n";} ],
52};
53
541;