]> git.proxmox.com Git - pmg-api.git/commitdiff
implement force_restart for cluster sync
authorDominik Csapak <d.csapak@proxmox.com>
Thu, 14 Nov 2019 11:18:52 +0000 (12:18 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 15 Nov 2019 08:44:53 +0000 (09:44 +0100)
the 'force_restart' hash was unused, but it is actually necessary to
restart the pmg-smtp-filter if the custom.cf has changed

use it for saving the daemon name that needs to be restarted, this
way we can reuse it in the future to force restart other daemons
or for different reasons if we need to

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
src/PMG/CLI/pmgcm.pm
src/PMG/Cluster.pm
src/PMG/Service/pmgmirror.pm

index c41c24d5d012905f10d7fd9e2d24213058f76f5b..59bdb06a77a99ef530658642a804d59bc286e4d4 100644 (file)
@@ -249,12 +249,19 @@ __PACKAGE__->register_method({
 
        print STDERR "syncing master configuration from '${master_ip}'\n";
 
-       PMG::Cluster::sync_config_from_master($master_name, $master_ip);
+       my $restart = PMG::Cluster::sync_config_from_master($master_name, $master_ip);
 
        my $cfg = PMG::Config->new();
 
        $cfg->rewrite_config(undef, 1);
 
+       if (scalar(keys %$restart)) {
+           print "please restart the following daemons:\n";
+           for my $service (sort keys %$restart) {
+               print "$service\n"
+           }
+       }
+
        return undef;
     }});
 
index fe802baf8719a0bd75f940944a1c23885764e36a..0980c68a8beb9173b709bf931528d7303204419e 100644 (file)
@@ -422,11 +422,12 @@ sub sync_config_from_master {
     my $force_restart = {};
 
     if ($cond_commit_synced_file->($sa_custom_cf, "${sa_conf_dir}/${sa_custom_cf}")) {
-       $force_restart->{spam} = 1;
+       $force_restart->{'pmg-smtp-filter'} = 1;
     }
 
     $cond_commit_synced_file->('pmg.conf');
 
+    return $force_restart;
 }
 
 sub sync_ruledb_from_master {
index 339bf7b52af9282d1de1967e9468105796b37dba..2655b90bacd7d88b32859e2d14062e9e9e6be9f9 100644 (file)
@@ -18,6 +18,7 @@ use PMG::RuleDB;
 use PMG::Cluster;
 use PMG::ClusterConfig;
 use PMG::Statistic;
+use PMG::Utils;
 
 use base qw(PVE::Daemon);
 
@@ -96,8 +97,9 @@ sub cluster_sync {
     my $master_ip = $cinfo->{master}->{ip};
     my $master_name = $cinfo->{master}->{name};
 
+    my $force_restart = {};
     if ($role ne 'master') {
-       PMG::Cluster::sync_config_from_master($master_name, $master_ip);
+       $force_restart = PMG::Cluster::sync_config_from_master($master_name, $master_ip);
     }
 
     my $csynctime = tv_interval($start_time);
@@ -164,6 +166,9 @@ sub cluster_sync {
                           "(files %.2f, database %.2f, config %.2f))",
                           $errcount, $cptime, $rsynctime, $dbtime, $csynctime));
 
+    foreach my $service (keys %$force_restart) {
+       PMG::Utils::service_cmd($service, 'restart');
+    }
 }
 
 sub run {