From 8093c6ab3b1435fa4aa348777b40b61780d4ffc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 21 Jul 2021 15:35:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Server/ServerManager.php | 5 ++++- Server/Worker/ServerWorker.php | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Server/ServerManager.php b/Server/ServerManager.php index 69b96e71..436c4dce 100644 --- a/Server/ServerManager.php +++ b/Server/ServerManager.php @@ -8,6 +8,7 @@ use ReflectionException; use Server\SInterface\CustomProcess; use Server\SInterface\TaskExecute; use Server\Task\ServerTask; +use Snowflake\Abstracts\Config; use Snowflake\Exception\NotFindClassException; use Snowflake\Snowflake; use Swoole\Http\Server as HServer; @@ -102,6 +103,7 @@ class ServerManager extends Abstracts\Server * @param null $redirect_stdin_and_stdout * @param int|null $pipe_type * @param bool $enable_coroutine + * @throws Exception */ public function addProcess(string|CustomProcess $customProcess, $redirect_stdin_and_stdout = null, ?int $pipe_type = SOCK_DGRAM, bool $enable_coroutine = true) { @@ -114,8 +116,9 @@ class ServerManager extends Abstracts\Server } /** @var Process $process */ $this->server->addProcess(new Process(function (Process $soloProcess) use ($customProcess) { + $system = sprintf('Process[%d].%s', $soloProcess->pid, Config::get('id', 'system-service')); if (Snowflake::getPlatform()->isLinux()) { - $soloProcess->name($customProcess->getProcessName($soloProcess)); + $soloProcess->name($system . '.' . $customProcess->getProcessName($soloProcess) . ' start.'); } $customProcess->onHandler($soloProcess); }, diff --git a/Server/Worker/ServerWorker.php b/Server/Worker/ServerWorker.php index 62bf9a01..f04c1b90 100644 --- a/Server/Worker/ServerWorker.php +++ b/Server/Worker/ServerWorker.php @@ -33,6 +33,8 @@ class ServerWorker extends \Server\Abstracts\Server $annotation = Snowflake::app()->getAnnotation(); $annotation->read(APP_PATH . 'app'); + debug(sprintf('Worker[%d]#%d start.', $server->worker_pid, $workerId)); + $this->runEvent(Constant::WORKER_START, null, [$server, $workerId]); if ($workerId >= $server->setting['worker_num'] + 1) { $loader = Snowflake::app()->getRouter(); @@ -91,7 +93,7 @@ class ServerWorker extends \Server\Abstracts\Server putenv('state=exit'); - Event::trigger(Event::SERVER_WORKER_EXIT, [$server, $worker_id]); + Event::trigger(Event::SERVER_WORKER_EXIT, [$server, $workerId]); Snowflake::getApp('logger')->insert(); }