This commit is contained in:
2021-07-21 15:35:40 +08:00
parent db3e6aadc7
commit 8093c6ab3b
2 changed files with 7 additions and 2 deletions
+4 -1
View File
@@ -8,6 +8,7 @@ use ReflectionException;
use Server\SInterface\CustomProcess; use Server\SInterface\CustomProcess;
use Server\SInterface\TaskExecute; use Server\SInterface\TaskExecute;
use Server\Task\ServerTask; use Server\Task\ServerTask;
use Snowflake\Abstracts\Config;
use Snowflake\Exception\NotFindClassException; use Snowflake\Exception\NotFindClassException;
use Snowflake\Snowflake; use Snowflake\Snowflake;
use Swoole\Http\Server as HServer; use Swoole\Http\Server as HServer;
@@ -102,6 +103,7 @@ class ServerManager extends Abstracts\Server
* @param null $redirect_stdin_and_stdout * @param null $redirect_stdin_and_stdout
* @param int|null $pipe_type * @param int|null $pipe_type
* @param bool $enable_coroutine * @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) 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 */ /** @var Process $process */
$this->server->addProcess(new Process(function (Process $soloProcess) use ($customProcess) { $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()) { if (Snowflake::getPlatform()->isLinux()) {
$soloProcess->name($customProcess->getProcessName($soloProcess)); $soloProcess->name($system . '.' . $customProcess->getProcessName($soloProcess) . ' start.');
} }
$customProcess->onHandler($soloProcess); $customProcess->onHandler($soloProcess);
}, },
+3 -1
View File
@@ -33,6 +33,8 @@ class ServerWorker extends \Server\Abstracts\Server
$annotation = Snowflake::app()->getAnnotation(); $annotation = Snowflake::app()->getAnnotation();
$annotation->read(APP_PATH . 'app'); $annotation->read(APP_PATH . 'app');
debug(sprintf('Worker[%d]#%d start.', $server->worker_pid, $workerId));
$this->runEvent(Constant::WORKER_START, null, [$server, $workerId]); $this->runEvent(Constant::WORKER_START, null, [$server, $workerId]);
if ($workerId >= $server->setting['worker_num'] + 1) { if ($workerId >= $server->setting['worker_num'] + 1) {
$loader = Snowflake::app()->getRouter(); $loader = Snowflake::app()->getRouter();
@@ -91,7 +93,7 @@ class ServerWorker extends \Server\Abstracts\Server
putenv('state=exit'); putenv('state=exit');
Event::trigger(Event::SERVER_WORKER_EXIT, [$server, $worker_id]); Event::trigger(Event::SERVER_WORKER_EXIT, [$server, $workerId]);
Snowflake::getApp('logger')->insert(); Snowflake::getApp('logger')->insert();
} }