2011-06-23 Koichiro Kikuchi <koichiro@rworks.jp>
* lib/PandoraFMS/Tools.pm: Checked if pandora_server is already running, in order to prevent multiple instances with same PID file from running. And made PID file permissions 644, rather than 666. * bin/pandora_server: Remove PID file on shutdown. * FreeBSD/pandora_server: Use -P option for PID file instead of pgrep. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4481 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
f9c88a4a40
commit
f4e3adea24
|
@ -1,3 +1,15 @@
|
||||||
|
2011-06-23 Koichiro Kikuchi <koichiro@rworks.jp>
|
||||||
|
|
||||||
|
* lib/PandoraFMS/Tools.pm: Checked if pandora_server is already
|
||||||
|
running, in order to prevent multiple instances with same PID
|
||||||
|
file from running. And made PID file permissions 644, rather
|
||||||
|
than 666.
|
||||||
|
|
||||||
|
* bin/pandora_server: Remove PID file on shutdown.
|
||||||
|
|
||||||
|
* FreeBSD/pandora_server: Use -P option for PID file instead of
|
||||||
|
pgrep.
|
||||||
|
|
||||||
2011-06-22 Ramon Novoa <rnovoa@artica.es>
|
2011-06-22 Ramon Novoa <rnovoa@artica.es>
|
||||||
|
|
||||||
* lib/PandoraFMS/Config.pm: Added a new SNMP server (enterprise).
|
* lib/PandoraFMS/Config.pm: Added a new SNMP server (enterprise).
|
||||||
|
|
|
@ -26,25 +26,11 @@ load_rc_config $name
|
||||||
|
|
||||||
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
|
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
|
||||||
|
|
||||||
command=/usr/local/bin/${name}
|
|
||||||
command_args="-D /usr/local/etc/pandora/pandora_server.conf"
|
|
||||||
|
|
||||||
pidfile=/var/run/$name.pid
|
pidfile=/var/run/$name.pid
|
||||||
|
command=/usr/local/bin/${name}
|
||||||
|
command_args="-D -P ${pidfile} /usr/local/etc/pandora/pandora_server.conf"
|
||||||
required_files="/usr/local/etc/pandora/pandora_server.conf"
|
required_files="/usr/local/etc/pandora/pandora_server.conf"
|
||||||
start_postcmd=start_postcmd
|
|
||||||
stop_postcmd=stop_postcmd
|
|
||||||
|
|
||||||
procname="/usr/local/bin/perl"
|
procname="/usr/local/bin/perl"
|
||||||
|
|
||||||
start_postcmd()
|
|
||||||
{
|
|
||||||
PANDORA_PID=`pgrep -f -j none $name`
|
|
||||||
echo $PANDORA_PID > $pidfile
|
|
||||||
}
|
|
||||||
|
|
||||||
stop_postcmd()
|
|
||||||
{
|
|
||||||
rm -f $pidfile
|
|
||||||
}
|
|
||||||
|
|
||||||
run_rc_command "$1"
|
run_rc_command "$1"
|
||||||
|
|
|
@ -56,6 +56,9 @@ sub pandora_shutdown () {
|
||||||
|
|
||||||
print_message (\%Config, ' [*] Shutting down ' . $Config{'servername'} . "(received signal)...\n", 1);
|
print_message (\%Config, ' [*] Shutting down ' . $Config{'servername'} . "(received signal)...\n", 1);
|
||||||
db_disconnect ($DBH);
|
db_disconnect ($DBH);
|
||||||
|
if ($Config{'PID'} ne "") {
|
||||||
|
unlink($Config{'PID'}) or logger (\%Config, "[W] Could not remove PID file: $!",1);
|
||||||
|
}
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -284,14 +284,26 @@ sub pandora_daemonize {
|
||||||
defined(my $pid = fork) or die "Can't fork: $!";
|
defined(my $pid = fork) or die "Can't fork: $!";
|
||||||
exit if $pid;
|
exit if $pid;
|
||||||
setsid or die "Can't start a new session: $!";
|
setsid or die "Can't start a new session: $!";
|
||||||
umask 0;
|
|
||||||
|
|
||||||
# Store PID of this process in file presented by config token
|
# Store PID of this process in file presented by config token
|
||||||
if ($pa_config->{'PID'} ne ""){
|
if ($pa_config->{'PID'} ne ""){
|
||||||
|
|
||||||
|
if ( -e $pa_config->{'PID'} && open (FILE, $pa_config->{'PID'})) {
|
||||||
|
$pid = <FILE> + 0;
|
||||||
|
close FILE;
|
||||||
|
|
||||||
|
# check if pandora_server is running
|
||||||
|
if (kill (0, $pid)) {
|
||||||
|
die "[FATAL] pandora_server already running, pid: $pid.";
|
||||||
|
}
|
||||||
|
logger ($pa_config, '[W] Stale PID file, overwriting.', 1);
|
||||||
|
}
|
||||||
|
umask 022;
|
||||||
open (FILE, "> ".$pa_config->{'PID'}) or die "[FATAL] Cannot open PIDfile at ".$pa_config->{'PID'};
|
open (FILE, "> ".$pa_config->{'PID'}) or die "[FATAL] Cannot open PIDfile at ".$pa_config->{'PID'};
|
||||||
print FILE "$$";
|
print FILE "$$";
|
||||||
close (FILE);
|
close (FILE);
|
||||||
}
|
}
|
||||||
|
umask 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue