This commit is contained in:
as2252258@163.com
2021-07-20 01:57:37 +08:00
parent 46bcbb4f4b
commit 43d0596c12
+3 -1
View File
@@ -26,8 +26,10 @@ class ServerWorker extends \Server\Abstracts\Server
*/ */
public function onWorkerStart(Server $server, int $workerId) public function onWorkerStart(Server $server, int $workerId)
{ {
$this->_setConfigCache($workerId);
$annotation = Snowflake::app()->getAnnotation(); $annotation = Snowflake::app()->getAnnotation();
$annotation->read(APP_PATH); $annotation->read(APP_PATH);
$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) {
$annotation->runtime(CONTROLLER_PATH); $annotation->runtime(CONTROLLER_PATH);
@@ -41,7 +43,7 @@ class ServerWorker extends \Server\Abstracts\Server
* @param $worker_id * @param $worker_id
* @throws Exception * @throws Exception
*/ */
private function setConfigs($worker_id) private function _setConfigCache($worker_id)
{ {
putenv('state=start'); putenv('state=start');
putenv('worker=' . $worker_id); putenv('worker=' . $worker_id);