Merge branch 'ent-8667-registros-duplicados-en-entornos-centralizados' into 'develop'

Ensure there are no duplicates in pandora_ha execution

See merge request artica/pandorafms!4753
This commit is contained in:
Daniel Rodriguez 2022-03-31 11:50:13 +00:00
commit 066ae12d43
1 changed files with 21 additions and 19 deletions

View File

@ -82,7 +82,11 @@ sub ha_daemonize($) {
# Fork!
defined(my $pid = fork) or die "Can't fork: $!";
if ($pid) {
exit if ($pid);
# Child inherits execution.
setsid or die "Can't start a new session: $!";
# Store PID of this process in file presented by config token
if ($PID_FILE ne "") {
if ( -e $PID_FILE && open (FILE, $PID_FILE)) {
@ -90,16 +94,14 @@ sub ha_daemonize($) {
close FILE;
# Check if pandora_ha is running.
die "[ERROR] pandora_ha is already running with pid: $pid." if (kill (0, $pid));
die "[ERROR] pandora_ha is already running with pid: $pid.\n" if (kill (0, $pid));
}
umask 0022;
open (FILE, '>', $PID_FILE) or die "[FATAL] $!";
print FILE $pid;
print FILE $$;
close (FILE);
}
exit;
}
setsid or die "Can't start a new session: $!";
}
########################################################################
@ -315,10 +317,10 @@ sub ha_main($) {
# Log to a separate file if needed.
$conf->{'log_file'} = $conf->{'ha_log_file'} if defined ($conf->{'ha_log_file'});
ha_daemonize($conf) if ($DAEMON == 1);
$Running = 1;
ha_daemonize($conf) if ($DAEMON == 1);
while ($Running) {
eval {
eval {