mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-30 01:05:39 +02:00
Add a watchdog for Tentacle Server to pandora_ha.
This commit is contained in:
parent
ea07bba78b
commit
8bc84bf0b4
@ -569,6 +569,10 @@ sub pandora_load_config {
|
|||||||
$pa_config->{'ncmserver_threads'} = 1; # 7.0 758
|
$pa_config->{'ncmserver_threads'} = 1; # 7.0 758
|
||||||
$pa_config->{'ncm_ssh_utility'} = '/usr/share/pandora_server/util/ncm_ssh_extension'; # 7.0 758
|
$pa_config->{'ncm_ssh_utility'} = '/usr/share/pandora_server/util/ncm_ssh_extension'; # 7.0 758
|
||||||
|
|
||||||
|
$pa_config->{"pandora_service_cmd"} = 'service pandora_server'; # 7.0 761
|
||||||
|
$pa_config->{"tentacle_service_cmd"} = 'service tentacle_serverd'; # 7.0 761
|
||||||
|
$pa_config->{"tentacle_service_watchdog"} = 1; # 7.0 761
|
||||||
|
|
||||||
# Check for UID0
|
# Check for UID0
|
||||||
if ($pa_config->{"quiet"} != 0){
|
if ($pa_config->{"quiet"} != 0){
|
||||||
if ($> == 0){
|
if ($> == 0){
|
||||||
@ -1314,6 +1318,12 @@ sub pandora_load_config {
|
|||||||
elsif ($parametro =~ m/^pandora_service_cmd\s(.*)/i) {
|
elsif ($parametro =~ m/^pandora_service_cmd\s(.*)/i) {
|
||||||
$pa_config->{'pandora_service_cmd'} = clean_blank($1);
|
$pa_config->{'pandora_service_cmd'} = clean_blank($1);
|
||||||
}
|
}
|
||||||
|
elsif ($parametro =~ m/^tentacle_service_cmd\s(.*)/i) {
|
||||||
|
$pa_config->{'tentacle_service_cmd'} = clean_blank($1);
|
||||||
|
}
|
||||||
|
elsif ($parametro =~ m/^tentacle_service_watchdog\s([0-1])/i) {
|
||||||
|
$pa_config->{'tentacle_service_watchdog'} = clean_blank($1);
|
||||||
|
}
|
||||||
elsif ($parametro =~ m/^splitbrain_autofix\s+([0-9]*)/i) {
|
elsif ($parametro =~ m/^splitbrain_autofix\s+([0-9]*)/i) {
|
||||||
$pa_config->{'splitbrain_autofix'} = clean_blank($1);
|
$pa_config->{'splitbrain_autofix'} = clean_blank($1);
|
||||||
}
|
}
|
||||||
|
@ -149,6 +149,9 @@ sub ha_load_pandora_conf($) {
|
|||||||
$conf->{'dbport'} = '3306' unless defined ($conf->{'dbport'});
|
$conf->{'dbport'} = '3306' unless defined ($conf->{'dbport'});
|
||||||
$conf->{'ha_interval'} = 10 unless defined ($conf->{'ha_interval'});
|
$conf->{'ha_interval'} = 10 unless defined ($conf->{'ha_interval'});
|
||||||
$conf->{'ha_monitoring_interval'} = 60 unless defined ($conf->{'ha_monitoring_interval'});
|
$conf->{'ha_monitoring_interval'} = 60 unless defined ($conf->{'ha_monitoring_interval'});
|
||||||
|
$conf->{'pandora_service_cmd'} = 'service pandora_server' unless defined($conf->{'pandora_service_cmd'});
|
||||||
|
$conf->{'tentacle_service_cmd'} = 'service tentacle_serverd' unless defined ($conf->{'tentacle_service_cmd'});
|
||||||
|
$conf->{'tentacle_service_watchdog'} = 1 unless defined ($conf->{'tentacle_service_watchdog'});
|
||||||
}
|
}
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
@ -167,8 +170,6 @@ sub ha_keep_pandora_running($$) {
|
|||||||
my $OSNAME = $^O;
|
my $OSNAME = $^O;
|
||||||
my $control_command;
|
my $control_command;
|
||||||
|
|
||||||
$conf->{'pandora_service_cmd'} = 'service pandora_server' unless defined($conf->{'pandora_service_cmd'});
|
|
||||||
|
|
||||||
# Check if all servers are running
|
# Check if all servers are running
|
||||||
# Restart if crashed or keep interval is over.
|
# Restart if crashed or keep interval is over.
|
||||||
my $component_last_contact = get_db_value(
|
my $component_last_contact = get_db_value(
|
||||||
@ -231,6 +232,25 @@ sub ha_keep_pandora_running($$) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Keep the Tentacle server running
|
||||||
|
##############################################################################
|
||||||
|
sub ha_keep_tentacle_running($$) {
|
||||||
|
my ($conf, $dbh) = @_;
|
||||||
|
|
||||||
|
return unless ($conf->{'tentacle_service_watchdog'} == 1);
|
||||||
|
|
||||||
|
# Try to get the PID of the service.
|
||||||
|
my $pid = `$conf->{'tentacle_service_cmd'} status | awk '{print \$NF*1}' | tr -d '\.'`;
|
||||||
|
|
||||||
|
# Not running.
|
||||||
|
if ($pid == 0) {
|
||||||
|
log_message($conf, 'LOG', 'Tentacle service not running.');
|
||||||
|
print ">> service not running...\n";
|
||||||
|
`$conf->{'tentacle_service_cmd'} start 2>/dev/null`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Update pandora services.
|
# Update pandora services.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@ -273,8 +293,6 @@ sub ha_update_server($$) {
|
|||||||
rmtree($workDir);
|
rmtree($workDir);
|
||||||
|
|
||||||
# Restart service
|
# Restart service
|
||||||
$config->{'pandora_service_cmd'} = 'service pandora_server'
|
|
||||||
unless defined($config->{'pandora_service_cmd'});
|
|
||||||
my $control_command = "restart-server";
|
my $control_command = "restart-server";
|
||||||
if ($OSNAME eq "freebsd") {
|
if ($OSNAME eq "freebsd") {
|
||||||
$control_command = "restart_server";
|
$control_command = "restart_server";
|
||||||
@ -355,6 +373,9 @@ sub ha_main($) {
|
|||||||
|
|
||||||
# Keep pandora running
|
# Keep pandora running
|
||||||
ha_keep_pandora_running($conf, $dbh);
|
ha_keep_pandora_running($conf, $dbh);
|
||||||
|
|
||||||
|
# Keep Tentacle running
|
||||||
|
ha_keep_tentacle_running($conf, $dbh);
|
||||||
|
|
||||||
# Are we the master?
|
# Are we the master?
|
||||||
pandora_set_master($conf, $dbh);
|
pandora_set_master($conf, $dbh);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user