Compare commits

...

3 Commits

Author SHA1 Message Date
as2252258 908c8719d3 eee 2026-06-24 20:17:54 +08:00
as2252258 69b845d924 eee 2026-06-12 23:57:18 +08:00
as2252258 d9c8344a29 eee 2026-04-17 16:31:59 +08:00
4 changed files with 22 additions and 20 deletions
+2 -1
View File
@@ -2,6 +2,7 @@
namespace Kiri\Server\Abstracts;
use Kiri\Di\HotReloadState;
use Kiri\Di\Inject\Container;
use Kiri\Error\StdoutLogger;
use Kiri\Events\EventProvider;
@@ -241,10 +242,10 @@ class FileWatcher extends AbstractProcess implements OnProcessInterface
$preview .= ' ...';
}
di(HotReloadState::class)->store($changedFiles);
di(StdoutLogger::class)->println('detected file changes, reloading server: ' . $preview);
$server = di(ServerInterface::class);
var_dump($server::class, get_class_methods($server));
if (method_exists($server, 'reload')) {
$server->reload();
}
+1 -1
View File
@@ -74,7 +74,7 @@ class OnServerWorker extends Kiri\Server\Abstracts\Server
try {
$this->dispatch->dispatch(new OnBeforeWorkerStart($server, $workerId));
if ($workerId < $server->setting['worker_num']) {
CoordinatorManager::utility(Coordinator::WORKER_START)->waite();
CoordinatorManager::utility(Coordinator::WORKER_START)->wait();
$this->dispatch->dispatch(new OnWorkerStart($server, $workerId));
} else {
+18 -17
View File
@@ -125,22 +125,23 @@ class ServerCommand extends Command
}
/**
* @param InputInterface $input
* @return int
* @throws
*/
protected function start(InputInterface $input): int
{
$this->asyncServer->addProcess(config('process', []));
if (\config('servers.reload.hot', false) === true) {
$this->asyncServer->addProcess([FileWatcher::class]);
} else {
di(Router::class)->scan_build_route();
}
$this->asyncServer->initCoreServers(config('servers.server', []), (int)$input->getOption('daemon'));
$this->asyncServer->start();
return 1;
}
/**
* @param InputInterface $input
* @return int
* @throws
*/
protected function start(InputInterface $input): int
{
$this->asyncServer->addProcess(config('process', []));
if (\config('servers.reload.hot', false) === true) {
$this->asyncServer->addProcess([FileWatcher::class]);
}
// Master 进程在 fork 前完成首次扫描,Worker 启动时不再重复全量扫描
// 避免每个 Worker 独立执行 opcache_compile_file + invalidateClasses 造成 OOM
di(Router::class)->scan_build_route();
$this->asyncServer->initCoreServers(config('servers.server', []), (int)$input->getOption('daemon'));
$this->asyncServer->start();
return 1;
}
}
+1 -1
View File
@@ -9,7 +9,7 @@
}
],
"require": {
"php": ">=8.4",
"php": ">=8.5",
"ext-json": "*",
"composer-runtime-api": "^2.0",
"psr/http-server-middleware": "^1.0",