mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-03-17 20:54:52 +08:00
init database in task worker (#271)
This commit is contained in:
parent
90a4c6803e
commit
e85e1e57b1
@ -130,6 +130,15 @@ class OnWorkerStart implements SwooleEvent
|
||||
Framework::saveProcessState(ZM_PROCESS_TASKWORKER, $server->worker_pid, ['worker_id' => $worker_id]);
|
||||
try {
|
||||
Framework::$server = $server;
|
||||
$this->initMySQLPool();
|
||||
$redis = ZMConfig::get('global', 'redis_config');
|
||||
if ($redis !== null && $redis['host'] != '') {
|
||||
if (!extension_loaded('redis')) {
|
||||
Console::error(zm_internal_errcode('E00029') . "Can not find redis extension.\n");
|
||||
} else {
|
||||
ZMRedisPool::init($redis);
|
||||
}
|
||||
}
|
||||
$this->loadAnnotations();
|
||||
Console::success('TaskWorker #' . $server->worker_id . ' started');
|
||||
} catch (Exception $e) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user