inject container into framework

This commit is contained in:
sunxyw
2022-04-10 00:58:07 +08:00
parent e37629aaea
commit 721c0834db
7 changed files with 244 additions and 118 deletions

View File

@@ -8,6 +8,7 @@ use Swoole\Server;
use ZM\Annotation\Swoole\SwooleHandler;
use ZM\Config\ZMConfig;
use ZM\Console\Console;
use ZM\Container\WorkerContainer;
use ZM\Event\SwooleEvent;
use ZM\Framework;
use ZM\Store\LightCache;
@@ -20,6 +21,11 @@ class OnWorkerStop implements SwooleEvent
{
public function onCall(Server $server, $worker_id)
{
WorkerContainer::getInstance()->flush();
if (Console::getLevel() >= 4) {
Console::debug(sprintf('Worker container [id=%d] flushed', $worker_id));
}
if ($worker_id == (ZMConfig::get('worker_cache')['worker'] ?? 0)) {
LightCache::savePersistence();
}