改名
This commit is contained in:
+29
-17
@@ -76,29 +76,41 @@ trait Action
|
|||||||
{
|
{
|
||||||
echo 'waite.';
|
echo 'waite.';
|
||||||
while ($server->isRunner()) {
|
while ($server->isRunner()) {
|
||||||
echo '.';
|
$this->masterIdCheck();
|
||||||
$pods = glob(storage(null, 'worker') . '/*');
|
|
||||||
if (count($pods) < 1) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
foreach ($pods as $pid) {
|
|
||||||
if (!file_exists($pid)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$content = file_get_contents($pid);
|
|
||||||
exec("ps -ax | awk '{ print $1 }' | grep -e '^{$content}$'", $output);
|
|
||||||
if (count($output) > 0) {
|
|
||||||
$this->closeByPid($content);
|
|
||||||
} else {
|
|
||||||
file_exists($pid) && @unlink($pid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
usleep(100);
|
usleep(100);
|
||||||
}
|
}
|
||||||
echo PHP_EOL;
|
echo PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WorkerId Iterator
|
||||||
|
*/
|
||||||
|
private function masterIdCheck()
|
||||||
|
{
|
||||||
|
echo '.';
|
||||||
|
$files = new \DirectoryIterator($this->getWorkerPath());
|
||||||
|
foreach ($files as $file) {
|
||||||
|
$content = file_get_contents($file->getRealPath());
|
||||||
|
exec("ps -ax | awk '{ print $1 }' | grep -e '^{$content}$'", $output);
|
||||||
|
if (count($output) > 0) {
|
||||||
|
$this->closeByPid($content);
|
||||||
|
} else {
|
||||||
|
@unlink($file->getRealPath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function getWorkerPath()
|
||||||
|
{
|
||||||
|
return "glob://" . ltrim(APP_PATH, '/') . '/storage/worker/*.sock';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $port
|
* @param $port
|
||||||
* @return bool|array
|
* @return bool|array
|
||||||
|
|||||||
Reference in New Issue
Block a user