defect 2966: fixed the issue that xcat pid files were put in /tmp/xcat which would be cleaned periodically. now move it to /var/run/xcat
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@13850 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
c2658bc27f
commit
944d18b0ce
@ -231,7 +231,7 @@ my $socket;
|
||||
my $retry=1;
|
||||
$SIG{USR2} = sub {
|
||||
if ($socket) { #do not mess with pid file except when we still have the socket.
|
||||
unlink("/tmp/xcat/installservice.pid"); close($socket); $quit=1;
|
||||
unlink("/var/run/xcat/installservice.pid"); close($socket); $quit=1;
|
||||
xCAT::MsgUtils->message("S","xcatd install monitor $$ quiescing");
|
||||
}
|
||||
};
|
||||
@ -246,7 +246,7 @@ my $socket;
|
||||
ReuseAddr => 1,
|
||||
Listen => 8192);
|
||||
}
|
||||
if (not $socket and open($installpidfile,"<","/tmp/xcat/installservice.pid")) { #if we couldn't get the socket, go to pid to figure out current owner
|
||||
if (not $socket and open($installpidfile,"<","/var/run/xcat/installservice.pid")) { #if we couldn't get the socket, go to pid to figure out current owner
|
||||
#TODO: lsof or similar may be a more accurate measure
|
||||
my $pid = <$installpidfile>;
|
||||
if ($pid) {
|
||||
@ -277,7 +277,7 @@ sleep 0.05; #up to 50 ms outage possible
|
||||
die;
|
||||
}
|
||||
#we have the socket, now we claim the pid file as our own
|
||||
open($installpidfile,">","/tmp/xcat/installservice.pid"); #if here, everyone else has unlinked installservicepid or doesn't care
|
||||
open($installpidfile,">","/var/run/xcat/installservice.pid"); #if here, everyone else has unlinked installservicepid or doesn't care
|
||||
print $installpidfile $$;
|
||||
close($installpidfile);
|
||||
until ($quit) {
|
||||
@ -436,10 +436,10 @@ if ($inet6support) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (open($installpidfile,"<","/tmp/xcat/installservice.pid")) {
|
||||
if (open($installpidfile,"<","/var/run/xcat/installservice.pid")) {
|
||||
my $pid = <$installpidfile>;
|
||||
if ($pid == $$) { #if our pid, unlink the file, otherwise, we managed to see the pid after someone else created it
|
||||
unlink("/tmp/xcat/installservice.pid");
|
||||
unlink("/var/run/xcat/installservice.pid");
|
||||
}
|
||||
close($installpidfile);
|
||||
}
|
||||
@ -461,7 +461,7 @@ sub do_udp_service { #This function opens up a UDP port
|
||||
$SIG{USR2} = sub {
|
||||
if ($socket) {
|
||||
#only clear out pid file when we still have socket.
|
||||
unlink("/tmp/xcat/udpservice.pid"); close($socket); $quit=1; $socket=0;
|
||||
unlink("/var/run/xcat/udpservice.pid"); close($socket); $quit=1; $socket=0;
|
||||
xCAT::MsgUtils->message("S","xcatd udp service $$ quiescing");
|
||||
}
|
||||
};
|
||||
@ -474,7 +474,7 @@ sub do_udp_service { #This function opens up a UDP port
|
||||
Proto => 'udp',
|
||||
Domain => AF_INET);
|
||||
}
|
||||
if (not $socket and open($udppidfile,"<","/tmp/xcat/udpservice.pid")) {
|
||||
if (not $socket and open($udppidfile,"<","/var/run/xcat/udpservice.pid")) {
|
||||
my $pid = <$udppidfile>;
|
||||
if ($pid) {
|
||||
$retry=100; #grace period for old instance to get out of the way, 5 seconds
|
||||
@ -504,7 +504,7 @@ sleep 0.05;
|
||||
die "Unable to start UDP on $port";
|
||||
}
|
||||
#only take udp pid if we get the socket
|
||||
open($udppidfile,">","/tmp/xcat/udpservice.pid"); #if here, everyone else has unlinked udpservicepid or doesn't care
|
||||
open($udppidfile,">","/var/run/xcat/udpservice.pid"); #if here, everyone else has unlinked udpservicepid or doesn't care
|
||||
print $udppidfile $$;
|
||||
close($udppidfile);
|
||||
$select->add($socket);
|
||||
@ -578,10 +578,10 @@ sleep 0.05;
|
||||
exit 1;
|
||||
}
|
||||
}
|
||||
if (open($udppidfile,"<","/tmp/xcat/udpservice.pid")) {
|
||||
if (open($udppidfile,"<","/var/run/xcat/udpservice.pid")) {
|
||||
my $pid = <$udppidfile>;
|
||||
if ($pid == $$) { #if our pid, unlink the file, otherwise, we managed to see the pid after someone else created it
|
||||
unlink("/tmp/xcat/udpservice.pid");
|
||||
unlink("/var/run/xcat/udpservice.pid");
|
||||
}
|
||||
close($udppidfile);
|
||||
}
|
||||
@ -798,7 +798,7 @@ my $listener;
|
||||
my $mainpidfile;
|
||||
$SIG{USR2} = sub {
|
||||
if ($listener) {
|
||||
unlink("/tmp/xcat/mainservice.pid"); close($listener); $quit=1; $listener=0;
|
||||
unlink("/var/run/xcat/mainservice.pid"); close($listener); $quit=1; $listener=0;
|
||||
xCAT::MsgUtils->message("S","xcatd main service $$ quiescing");
|
||||
}
|
||||
};
|
||||
@ -815,7 +815,7 @@ $SIG{USR2} = sub {
|
||||
Reuse => 1,
|
||||
);
|
||||
}
|
||||
if (not $listener and open($mainpidfile,"<","/tmp/xcat/mainservice.pid")) {
|
||||
if (not $listener and open($mainpidfile,"<","/var/run/xcat/mainservice.pid")) {
|
||||
my $pid = <$mainpidfile>;
|
||||
if ($pid) {
|
||||
$retry=100; #grace period for old instance to get out of the way, 5 seconds
|
||||
@ -855,7 +855,7 @@ unless ($listener) {
|
||||
die "ERROR:Unable to start xCAT service on port $port.";
|
||||
}
|
||||
#only write to pid file if we have listener, listener ownership serves as lock to protect integrity
|
||||
open($mainpidfile,">","/tmp/xcat/mainservice.pid"); #if here, everyone else has unlinked mainservicepid or doesn't care
|
||||
open($mainpidfile,">","/var/run/xcat/mainservice.pid"); #if here, everyone else has unlinked mainservicepid or doesn't care
|
||||
print $mainpidfile $$;
|
||||
close($mainpidfile);
|
||||
closelog();
|
||||
@ -959,10 +959,10 @@ if ($inet6support) {
|
||||
$sslclients++; #THROTTLE
|
||||
$cnnection->close();
|
||||
}
|
||||
if (open($mainpidfile,"<","/tmp/xcat/mainservice.pid")) {
|
||||
if (open($mainpidfile,"<","/var/run/xcat/mainservice.pid")) {
|
||||
my $pid = <$mainpidfile>;
|
||||
if ($pid == $$) { #if our pid, unlink the file, otherwise, we managed to see the pid after someone else created it
|
||||
unlink("/tmp/xcat/mainservice.pid");
|
||||
unlink("/var/run/xcat/mainservice.pid");
|
||||
}
|
||||
close($mainpidfile);
|
||||
}
|
||||
|
@ -133,6 +133,9 @@ cp LICENSE.html $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT
|
||||
|
||||
|
||||
%post
|
||||
# create dir for the current pid
|
||||
mkdir -p /var/run/xcat
|
||||
|
||||
%ifnos linux
|
||||
. /etc/profile
|
||||
%else
|
||||
@ -142,6 +145,16 @@ cp -f $RPM_INSTALL_PREFIX0/share/xcat/scripts/xHRM /install/postscripts/
|
||||
if [ "$1" = "1" ]; then #Only if installing for the first time..
|
||||
$RPM_INSTALL_PREFIX0/sbin/xcatconfig -i
|
||||
else
|
||||
if [ -r "/tmp/xcat/installservice.pid" ]; then
|
||||
mv /tmp/xcat/installservice.pid /var/run/xcat/installservice.pid
|
||||
fi
|
||||
if [ -r "/tmp/xcat/udpservice.pid" ]; then
|
||||
mv /tmp/xcat/udpservice.pid /var/run/xcat/udpservice.pid
|
||||
fi
|
||||
if [ -r "/tmp/xcat/mainservice.pid" ]; then
|
||||
mv /tmp/xcat/mainservice.pid /var/run/xcat/mainservice.pid
|
||||
fi
|
||||
|
||||
$RPM_INSTALL_PREFIX0/sbin/xcatconfig -u
|
||||
fi
|
||||
exit 0
|
||||
|
Loading…
Reference in New Issue
Block a user