改名
This commit is contained in:
+19
-14
@@ -48,23 +48,26 @@ trait Action
|
|||||||
*/
|
*/
|
||||||
private function _shutdown($server)
|
private function _shutdown($server)
|
||||||
{
|
{
|
||||||
$socket = storage('socket.sock');
|
$content = file_get_contents($this->getPidFile());
|
||||||
if (!file_exists($socket)) {
|
if (empty($content)) {
|
||||||
$this->close($server);
|
$this->close($server);
|
||||||
} else {
|
} else {
|
||||||
$pathId = file_get_contents($socket);
|
exec("ps -ef $content | grep $content", $output);
|
||||||
@unlink($socket);
|
|
||||||
if (empty($pathId)) {
|
|
||||||
$this->close($server);
|
|
||||||
} else {
|
|
||||||
exec("ps -ef $pathId | grep $pathId", $output);
|
|
||||||
if (!empty($output)) {
|
if (!empty($output)) {
|
||||||
exec("kill -TERM $pathId");
|
exec("kill -15 $content");
|
||||||
}
|
}
|
||||||
$this->close($server);
|
$this->close($server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Snowflake::clearWorkerId();
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
* @throws ComponentException
|
||||||
|
*/
|
||||||
|
private function getPidFile(): string
|
||||||
|
{
|
||||||
|
return Snowflake::app()->getSwoole()->setting['pid_file'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -144,10 +147,12 @@ trait Action
|
|||||||
*/
|
*/
|
||||||
private function closeByPid($pid)
|
private function closeByPid($pid)
|
||||||
{
|
{
|
||||||
exec("ps -ef $pid | grep $pid", $output);
|
exec("ps -ef | grep $pid | grep -v grep | grep -v kill
|
||||||
if (!empty($output)) {
|
if [ $? -eq 0 ];then
|
||||||
exec("kill -TERM $pid");
|
kill -9 `ps -ef | grep $pid | grep -v grep | grep -v kill | awk '{print $2}'`
|
||||||
}
|
else
|
||||||
|
echo $pid' No Found Process'
|
||||||
|
fi");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,8 +26,6 @@ class OnManagerStop extends Callback
|
|||||||
$this->warning('manager stop.');
|
$this->warning('manager stop.');
|
||||||
|
|
||||||
fire(Event::SERVER_MANAGER_STOP, [$server]);
|
fire(Event::SERVER_MANAGER_STOP, [$server]);
|
||||||
|
|
||||||
Snowflake::clearWorkerId();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -169,22 +169,6 @@ class Snowflake
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public static function clearWorkerId()
|
|
||||||
{
|
|
||||||
$dir = storage(null, 'worker');
|
|
||||||
foreach (glob($dir . '/*') as $file) {
|
|
||||||
clearstatcache();
|
|
||||||
if (!file_exists($file)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
@unlink($file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $fileName
|
* @param $fileName
|
||||||
* @param $content
|
* @param $content
|
||||||
|
|||||||
Reference in New Issue
Block a user