This commit is contained in:
2021-03-02 12:39:01 +08:00
parent 53b8262588
commit 26a4b8190a
2 changed files with 6 additions and 6 deletions
+4 -4
View File
@@ -56,7 +56,7 @@ trait Action
return; return;
} }
$content = file_get_contents($pid_file); $content = file_get_contents($pid_file);
Coroutine\System::exec("ps -ef $content | grep $content", $output); $output = Coroutine\System::exec("ps -ef $content | grep $content");
if (!empty($output)) { if (!empty($output)) {
Coroutine\System::exec("kill -15 $content"); Coroutine\System::exec("kill -15 $content");
} }
@@ -108,7 +108,7 @@ trait Action
} }
foreach ($files as $file) { foreach ($files as $file) {
$content = file_get_contents($file->getRealPath()); $content = file_get_contents($file->getRealPath());
Coroutine\System::exec("ps -ax | awk '{ print $1 }' | grep -e '^{$content}$'", $output); $output = Coroutine\System::exec("ps -ax | awk '{ print $1 }' | grep -e '^{$content}$'");
if (count($output) > 0) { if (count($output) > 0) {
$this->closeByPid($content); $this->closeByPid($content);
} else { } else {
@@ -138,9 +138,9 @@ trait Action
return false; return false;
} }
if (Snowflake::isLinux()) { if (Snowflake::isLinux()) {
Coroutine\System::exec('netstat -tunlp | grep ' . $port, $output); $output = Coroutine\System::exec('netstat -tunlp | grep ' . $port);
} else { } else {
Coroutine\System::exec('lsof -i :' . $port . ' | grep -i "LISTEN"', $output); $output = Coroutine\System::exec('lsof -i :' . $port . ' | grep -i "LISTEN"');
} }
if (empty($output)) { if (empty($output)) {
return false; return false;
+2 -2
View File
@@ -180,9 +180,9 @@ class Server extends HttpService
} }
foreach ($port as $value) { foreach ($port as $value) {
if (Snowflake::isLinux()) { if (Snowflake::isLinux()) {
Coroutine\System::exec('netstat -tunlp | grep ' . $value['port'], $output); $output = Coroutine\System::exec('netstat -tunlp | grep ' . $value['port']);
} else { } else {
Coroutine\System::exec('lsof -i :' . $value['port'] . ' | grep -i "LISTEN"', $output); $output = Coroutine\System::exec('lsof -i :' . $value['port'] . ' | grep -i "LISTEN"');
} }
if (!empty($output)) { if (!empty($output)) {
return true; return true;