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(); }