modify
This commit is contained in:
@@ -8,6 +8,7 @@ use Exception;
|
|||||||
use HttpServer\Abstracts\Callback;
|
use HttpServer\Abstracts\Callback;
|
||||||
use Snowflake\Event;
|
use Snowflake\Event;
|
||||||
use Snowflake\Exception\ConfigException;
|
use Snowflake\Exception\ConfigException;
|
||||||
|
use Snowflake\Runtime;
|
||||||
use Snowflake\Snowflake;
|
use Snowflake\Snowflake;
|
||||||
use Swoole\Coroutine;
|
use Swoole\Coroutine;
|
||||||
use Swoole\Coroutine\System;
|
use Swoole\Coroutine\System;
|
||||||
@@ -34,14 +35,13 @@ class OnWorkerStart extends Callback
|
|||||||
putenv('worker=' . $worker_id);
|
putenv('worker=' . $worker_id);
|
||||||
|
|
||||||
$annotation = Snowflake::app()->getAnnotation();
|
$annotation = Snowflake::app()->getAnnotation();
|
||||||
|
$annotation->setLoader(unserialize(file_get_contents(storage(Runtime::CACHE_NAME))));
|
||||||
if ($worker_id >= $server->setting['worker_num']) {
|
if ($worker_id >= $server->setting['worker_num']) {
|
||||||
$annotation->read(MODEL_PATH, 'App');
|
|
||||||
$annotation->runtime(APP_PATH, [CONTROLLER_PATH, TASK_PATH, LISTENER_PATH]);
|
$annotation->runtime(APP_PATH, [CONTROLLER_PATH, TASK_PATH, LISTENER_PATH]);
|
||||||
$this->onTask($server, $annotation);
|
$this->onTask($server, $annotation);
|
||||||
} else {
|
} else {
|
||||||
$annotation->read(directory('app'), 'App');
|
$annotation->runtime(CONTROLLER_PATH);
|
||||||
$annotation->runtime(directory('app'));
|
$annotation->runtime(directory('app'), [CONTROLLER_PATH]);
|
||||||
|
|
||||||
$this->onWorker($server, $annotation);
|
$this->onWorker($server, $annotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -22,6 +22,9 @@ class Runtime extends Command
|
|||||||
public string $description = 'create app file cache';
|
public string $description = 'create app file cache';
|
||||||
|
|
||||||
|
|
||||||
|
const CACHE_NAME = '.runtime.cache';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Input $dtl
|
* @param Input $dtl
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
@@ -31,7 +34,7 @@ class Runtime extends Command
|
|||||||
// TODO: Implement onHandler() method.
|
// TODO: Implement onHandler() method.
|
||||||
$annotation = Snowflake::app()->getAnnotation();
|
$annotation = Snowflake::app()->getAnnotation();
|
||||||
|
|
||||||
$runtime = storage('runtime.php');
|
$runtime = storage(static::CACHE_NAME);
|
||||||
|
|
||||||
Snowflake::writeFile($runtime, serialize($annotation->getLoader()));
|
Snowflake::writeFile($runtime, serialize($annotation->getLoader()));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user