]> git.proxmox.com Git - pve-ha-manager.git/commitdiff
improve manager livecycle, add cleanup
authorDietmar Maurer <dietmar@proxmox.com>
Mon, 1 Dec 2014 10:14:21 +0000 (11:14 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 1 Dec 2014 10:14:21 +0000 (11:14 +0100)
PVE/HA/Manager.pm
pve-ha-manager

index a04dcc0c685ec666468db1b14fefd7fc8b61c078..5137c86f538cb9032698cd0ba518c48af92a143f 100644 (file)
@@ -19,6 +19,12 @@ sub new {
     return $self;
 }
 
+sub cleanup {
+    my ($self) = @_;
+
+    # todo: ?
+}
+
 sub manage {
     my ($self) = @_;
 
index 9a11bdde3df0575edae4ecc848b74fc158fca182..f3b9513d655fbc6b09ff2806225c388c91ee5914 100755 (executable)
@@ -29,6 +29,7 @@ if ($testdir) {
 }
 
 my $status;
+my $manager;
 
 sub set_local_status {
     my ($new_status) = @_;
@@ -40,6 +41,15 @@ sub set_local_status {
     $status = $new_status;
 
     $haenv->write_local_status($status);
+
+    if ($status eq 'master') {
+       $manager = PVE::HA::Manager->new($haenv);
+    } else {
+       if ($manager) {
+           $manager->cleanup();
+           $manager = undef;
+       }
+    }
 }
 
 sub get_manager_lock {
@@ -80,8 +90,6 @@ if ($status eq 'master') {
 
 $haenv->log('info', "starting simulation environment (status = $status)");
 
-my $manager = PVE::HA::Manager->new($haenv);
-
 eval {
 
     for (;;) {
@@ -109,6 +117,8 @@ eval {
 
        } elsif ($status eq 'master') {
 
+           die "no manager" if !defined($manager);
+
            my $startime = $haenv->get_time();
 
            my $max_time = 10;