modify
This commit is contained in:
@@ -56,7 +56,6 @@ class OnWorkerStart extends Callback
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Server $server
|
* @param Server $server
|
||||||
* @param int $workerId
|
* @param int $workerId
|
||||||
@@ -65,14 +64,14 @@ class OnWorkerStart extends Callback
|
|||||||
public function onTaskSignal(Server $server, int $workerId)
|
public function onTaskSignal(Server $server, int $workerId)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$sigkill = Coroutine::waitSignal(SIGKILL | SIGUSR1);
|
$sigkill = Coroutine::waitSignal(SIGTERM | SIGKILL | SIGUSR2 | SIGUSR1);
|
||||||
var_dump($sigkill);
|
var_dump($sigkill);
|
||||||
if ($sigkill !== false) {
|
if ($sigkill !== false) {
|
||||||
while (Snowflake::app()->isRun()) {
|
while (Snowflake::app()->isRun()) {
|
||||||
Coroutine::sleep(1);
|
Coroutine::sleep(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$server->stop($workerId);
|
$server->stop();
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
$this->addError($exception);
|
$this->addError($exception);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -244,9 +244,9 @@ class Snowflake
|
|||||||
*/
|
*/
|
||||||
public static function getMasterPid(): bool|string
|
public static function getMasterPid(): bool|string
|
||||||
{
|
{
|
||||||
$default = APP_PATH . 'storage/server.pid';
|
$pid = Snowflake::app()->getSwoole()->setting['pid_file'];
|
||||||
$server = Config::get('settings.pid_file', false, $default);
|
|
||||||
return file_get_contents($server);
|
return file_get_contents($pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -389,7 +389,7 @@ class Snowflake
|
|||||||
*/
|
*/
|
||||||
public static function reload(): mixed
|
public static function reload(): mixed
|
||||||
{
|
{
|
||||||
return Process::kill((int)Snowflake::app()->getSwoole()->getMasterPid(),SIGUSR1);
|
return Process::kill((int)Snowflake::getMasterPid(),SIGUSR1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user