modify
This commit is contained in:
@@ -6,7 +6,9 @@ namespace Server\Abstracts;
|
||||
|
||||
use Closure;
|
||||
use Exception;
|
||||
use Snowflake\Abstracts\Config;
|
||||
use Snowflake\Event;
|
||||
use Snowflake\Exception\ConfigException;
|
||||
use Snowflake\Snowflake;
|
||||
|
||||
|
||||
@@ -24,6 +26,25 @@ abstract class Server
|
||||
protected Event $_event;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param $prefix
|
||||
* @throws ConfigException
|
||||
*/
|
||||
protected function setProcessName($prefix)
|
||||
{
|
||||
if (Snowflake::getPlatform()->isMac()) {
|
||||
return;
|
||||
}
|
||||
$name = Config::get('id', 'system-service');
|
||||
if (!empty($prefix)) {
|
||||
$name .= '.' . $prefix;
|
||||
}
|
||||
swoole_set_process_name($name);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Server constructor.
|
||||
* @throws Exception
|
||||
|
||||
@@ -22,7 +22,9 @@ class ServerDefaultEvent extends Server
|
||||
*/
|
||||
public function onStart(\Swoole\Server $server)
|
||||
{
|
||||
$this->runEvent(Constant::START, null, [$server]);
|
||||
$this->setProcessName(sprintf('start[%d].server', $server->worker_pid));
|
||||
|
||||
$this->runEvent(Constant::START, null, [$server]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -19,7 +19,9 @@ class ServerManager extends Server
|
||||
*/
|
||||
public function onManagerStart(\Swoole\Server $server)
|
||||
{
|
||||
$this->runEvent(Constant::MANAGER_START, null, [$server]);
|
||||
$this->setProcessName(sprintf('manger[%d].0', $server->worker_pid));
|
||||
|
||||
$this->runEvent(Constant::MANAGER_START, null, [$server]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -68,22 +68,6 @@ class ServerWorker extends \Server\Abstracts\Server
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $prefix
|
||||
* @throws ConfigException
|
||||
*/
|
||||
private function setProcessName($prefix)
|
||||
{
|
||||
if (Snowflake::getPlatform()->isMac()) {
|
||||
return;
|
||||
}
|
||||
$name = Config::get('id', 'system-service');
|
||||
if (!empty($prefix)) {
|
||||
$name .= '.' . $prefix;
|
||||
}
|
||||
swoole_set_process_name($name);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $worker_id
|
||||
|
||||
Reference in New Issue
Block a user