Fix the service runtime
- The trim is required - To prevent an error by using: ?? ''
This commit is contained in:
@@ -57,9 +57,9 @@
|
|||||||
if (!function_exists('is_running')) {
|
if (!function_exists('is_running')) {
|
||||||
function is_running(string $name) {
|
function is_running(string $name) {
|
||||||
$name = escapeshellarg($name);
|
$name = escapeshellarg($name);
|
||||||
$pid = shell_exec("ps -aux | grep $name | grep -v grep | awk '{print \$2}' | head -n 1");
|
$pid = trim(shell_exec("ps -aux | grep $name | grep -v grep | awk '{print \$2}' | head -n 1") ?? '');
|
||||||
if ($pid && is_numeric($pid)) {
|
if ($pid && is_numeric($pid)) {
|
||||||
$etime = shell_exec("ps -p $pid -o etime= | tr -d '\n'");
|
$etime = trim(shell_exec("ps -p $pid -o etime= | tr -d '\n'") ?? '');
|
||||||
return ['running' => true, 'pid' => $pid, 'etime' => $etime];
|
return ['running' => true, 'pid' => $pid, 'etime' => $etime];
|
||||||
}
|
}
|
||||||
return ['running' => false, 'pid' => null, 'etime' => null];
|
return ['running' => false, 'pid' => null, 'etime' => null];
|
||||||
|
|||||||
Reference in New Issue
Block a user