This commit is contained in:
as2252258@163.com
2021-04-11 19:08:36 +08:00
parent 76fab90abb
commit 91de213fb0
+39 -38
View File
@@ -20,52 +20,53 @@ use Swoole\Coroutine\System;
abstract class Process extends \Swoole\Process implements SProcess abstract class Process extends \Swoole\Process implements SProcess
{ {
/** @var Application $application */ /** @var Application $application */
protected Application $application; protected Application $application;
/** /**
* 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);
$this->application = $application; $this->application = $application;
Snowflake::setProcessId($this->pid); Snowflake::setProcessId($this->pid);
// $content = System::readFile(storage('runtime.php')); $content = System::readFile(storage('runtime.php'));
// $annotation = Snowflake::app()->getAnnotation(); $annotation = Snowflake::app()->getAnnotation();
// $annotation->setLoader(unserialize($content)); $annotation->setLoader(unserialize($content));
} $annotation->runtime(APP_PATH . 'app/Kafka');
}
/** /**
* @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()); name($process->pid, $this->getPrefix());
} }
$this->onHandler($process); $this->onHandler($process);
} }
/** /**
* @return string * @return string
*/ */
#[Pure] private function getPrefix(): string #[Pure] private function getPrefix(): string
{ {
return get_called_class(); return get_called_class();
} }
} }