This commit is contained in:
as2252258@163.com
2021-04-09 03:16:04 +08:00
parent b654e7b76e
commit 61a254a24e
+4 -4
View File
@@ -26,7 +26,7 @@ class OnWorkerStart extends Callback
$runtime = file_get_contents(storage('runtime.php')); $runtime = file_get_contents(storage('runtime.php'));
$annotation = Snowflake::app()->getAnnotation(); $annotation = Snowflake::app()->getAnnotation();
$annotation->setLoader(unserialize($runtime)); $annotation->setLoader(unserialize($runtime));
if ($isWorker) { if ($isWorker === true) {
$annotation->runtime(CONTROLLER_PATH); $annotation->runtime(CONTROLLER_PATH);
$annotation->runtime(APP_PATH, CONTROLLER_PATH); $annotation->runtime(APP_PATH, CONTROLLER_PATH);
} else { } else {
@@ -48,7 +48,7 @@ class OnWorkerStart extends Callback
putenv('state=start'); putenv('state=start');
putenv('worker=' . $worker_id); putenv('worker=' . $worker_id);
$isWorker = $this->injectLoader($this->isWorker($worker_id)); $isWorker = $this->injectLoader($this->isWorker($server, $worker_id));
$this->{$isWorker ? 'onWorker' : 'onTask'}($server); $this->{$isWorker ? 'onWorker' : 'onTask'}($server);
} }
@@ -59,9 +59,9 @@ class OnWorkerStart extends Callback
* @param int $worker_id * @param int $worker_id
* @return bool * @return bool
*/ */
private function isWorker(int $worker_id): bool private function isWorker($server, int $worker_id): bool
{ {
return $worker_id < $this->server->setting['worker_num']; return $worker_id < $server->setting['worker_num'];
} }