]> git.proxmox.com Git - pve-ha-manager.git/blame_incremental - pve-ha-crm
fixup watchdog to cleanly compile with systemd
[pve-ha-manager.git] / pve-ha-crm
... / ...
CommitLineData
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use PVE::SafeSyslog;
6use PVE::Daemon;
7use Data::Dumper;
8use PVE::RPCEnvironment;
9
10use PVE::HA::Env;
11use PVE::HA::Env::PVE2;
12use PVE::HA::CRM;
13
14use base qw(PVE::Daemon);
15
16my $cmdline = [$0, @ARGV];
17
18my %daemon_options = (stop_wait_time => 5);
19
20my $daemon = __PACKAGE__->new('pve-ha-crm', $cmdline, %daemon_options);
21
22my $rpcenv = PVE::RPCEnvironment->init('cli');
23
24$rpcenv->init_request();
25$rpcenv->set_language($ENV{LANG});
26$rpcenv->set_user('root@pam');
27
28sub run {
29 my ($self) = @_;
30
31 $self->{haenv} = PVE::HA::Env->new('PVE::HA::Env::PVE2', $self->{nodename});
32
33 $self->{crm} = PVE::HA::CRM->new($self->{haenv});
34
35 for (;;) {
36 $self->{haenv}->loop_start_hook();
37
38 my $repeat = $self->{crm}->do_one_iteration();
39
40 $self->{haenv}->loop_end_hook();
41
42 last if !$repeat;
43 }
44}
45
46sub shutdown {
47 my ($self) = @_;
48
49 $self->{crm}->shutdown_request();
50}
51
52$daemon->register_start_command();
53$daemon->register_stop_command();
54$daemon->register_status_command();
55
56my $cmddef = {
57 start => [ __PACKAGE__, 'start', []],
58 stop => [ __PACKAGE__, 'stop', []],
59 status => [ __PACKAGE__, 'status', [], undef, sub { print shift . "\n";} ],
60};
61
62my $cmd = shift;
63
64PVE::CLIHandler::handle_cmd($cmddef, $0, $cmd, \@ARGV, undef, $0);
65
66exit (0);
67
68__END__
69
70=head1 NAME
71
72pve-ha-crm - PVE Cluster Ressource Manager Daemon
73
74=head1 SYNOPSIS
75
76=include synopsis
77
78=head1 DESCRIPTION
79
80This is the Cluster Ressource Manager.
81
82=include pve_copyright