This commit is contained in:
as2252258@163.com
2021-03-01 01:07:29 +08:00
parent be20940927
commit ef02721526
2 changed files with 15 additions and 18 deletions
+14 -16
View File
@@ -23,7 +23,7 @@ class OnWorkerStart extends Callback
{ {
/** @var int|string 重启信号 */ /** @var int|string 重启信号 */
private int $signal = SIGUSR1 | SIGUSR2; private int $signal = SIGUSR1 | SIGUSR2 | SIGTERM;
/** @var bool 是否打印 */ /** @var bool 是否打印 */
@@ -55,7 +55,6 @@ class OnWorkerStart extends Callback
} }
/** /**
* @param Server $server * @param Server $server
* @param int $worker_id * @param int $worker_id
@@ -99,21 +98,20 @@ class OnWorkerStart extends Callback
*/ */
public function onSignal($server, $worker_id) public function onSignal($server, $worker_id)
{ {
$env = ucfirst(Snowflake::getEnvironmental());
// $env = ucfirst(Snowflake::getEnvironmental()); $receive = Coroutine::waitSignal($this->signal, -1);
// while ($receive === true) {
// $receive = Coroutine::waitSignal($this->signal, 30); if ($this->isPrint === false) {
// while ($receive === true) { $this->warning(sprintf('Receive %s#%d stop event.', $env, $worker_id));
// if ($this->isPrint === false) { $this->isPrint = true;
// $this->warning(sprintf('Receive %s#%d stop event.', $env, $worker_id)); }
// $this->isPrint = true; if (!Snowflake::app()->isRun()) {
// } break;
// if (!Snowflake::app()->isRun()) { }
// break; sleep(1);
// } }
// sleep(1); return $server->stop($worker_id);
// }
// return $server->stop($worker_id);
} }
+1 -2
View File
@@ -393,9 +393,8 @@ class Snowflake
*/ */
public static function reload(): mixed public static function reload(): mixed
{ {
// $pid = Snowflake::app()->getSwoole()->master_pid; return Snowflake::app()->getSwoole()->reload();
var_dump(Snowflake::getMasterPid());
return Process::kill((int)Snowflake::getMasterPid(), SIGUSR1); return Process::kill((int)Snowflake::getMasterPid(), SIGUSR1);
} }