mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Fix service parent class failed to remove PID file after shutdown (#7422)
Fixes the following: - The service would exit but fail to remove the PID file when the shutdown command was sent to the service. Added the following: - Better feedback during service start up if the PID fails to be created - Appropriate POSIX error codes on failure of modifying the PID file
This commit is contained in:
@@ -299,12 +299,12 @@ abstract class service {
|
||||
if (function_exists('posix_getsid')) {
|
||||
if (posix_getsid($pid) !== false) {
|
||||
//return the pid for reloading configuration
|
||||
return $pid;
|
||||
return intval($pid);
|
||||
}
|
||||
} else {
|
||||
if (file_exists('/proc/' . $pid)) {
|
||||
//return the pid for reloading configuration
|
||||
return $pid;
|
||||
return intval($pid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -321,7 +321,11 @@ abstract class service {
|
||||
|
||||
// Remove the old pid file
|
||||
if (file_exists(self::$pid_file)) {
|
||||
unlink(self::$pid_file);
|
||||
if (is_writable(self::$pid_file)) {
|
||||
unlink(self::$pid_file);
|
||||
} else {
|
||||
throw new \RuntimeException("Unable to write to PID file " . self::$pid_file, 73); //Unix error code 73 - unable to write/create file
|
||||
}
|
||||
}
|
||||
|
||||
// Show the details to the user
|
||||
@@ -330,7 +334,10 @@ abstract class service {
|
||||
self::log("PID File : " . self::$pid_file, LOG_INFO);
|
||||
|
||||
// Save the pid file
|
||||
file_put_contents(self::$pid_file, $pid);
|
||||
$success = file_put_contents(self::$pid_file, $pid);
|
||||
if ($success === false) {
|
||||
throw new \RuntimeException("Failed writing to PID file " . self::$pid_file, 74); //Unix error code 74 - I/O error
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user