改名
This commit is contained in:
+35
-40
@@ -18,50 +18,45 @@ abstract class Process extends \Swoole\Process implements SProcess
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process constructor.
|
* Process constructor.
|
||||||
* @param $application
|
* @param $application
|
||||||
* @param $name
|
* @param $name
|
||||||
* @param bool $enable_coroutine
|
* @param bool $enable_coroutine
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function __construct($application, $name, $enable_coroutine = true)
|
public function __construct($application, $name, $enable_coroutine = true)
|
||||||
{
|
{
|
||||||
parent::__construct([$this, '_load'], false, 1, $enable_coroutine);
|
parent::__construct([$this, '_load'], false, 1, $enable_coroutine);
|
||||||
Snowflake::setProcessId($this->pid);
|
Snowflake::setProcessId($this->pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Process $process
|
* @param Process $process
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function _load(Process $process)
|
public function _load(Process $process)
|
||||||
{
|
{
|
||||||
putenv('environmental=' . Snowflake::PROCESS);
|
putenv('environmental=' . Snowflake::PROCESS);
|
||||||
|
|
||||||
fire(Event::SERVER_WORKER_START);
|
fire(Event::SERVER_WORKER_START);
|
||||||
if (Snowflake::getPlatform()->isLinux()) {
|
if (Snowflake::getPlatform()->isLinux()) {
|
||||||
name($process->pid, $this->getPrefix());
|
swoole_set_process_name($this->getProcessName());
|
||||||
}
|
}
|
||||||
if (method_exists($this, 'before')) {
|
if (method_exists($this, 'before')) {
|
||||||
$this->before($process);
|
$this->before($process);
|
||||||
}
|
}
|
||||||
if (!Snowflake::getPlatform()->isMac()) {
|
$this->onHandler($process);
|
||||||
if (method_exists($this, 'getProcessName')) {
|
}
|
||||||
swoole_set_process_name($this->getProcessName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$this->onHandler($process);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
#[Pure] private function getPrefix(): string
|
#[Pure] private function getPrefix(): string
|
||||||
{
|
{
|
||||||
return static::class;
|
return static::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user