protected function _initPipeEvents($process, $workerType) { \Daemon\Library\Ipc\Shared::setCurrentTaskTable($process->pid, array('taskNum' => 0, 'workerType' => $workerType)); $objMaster = \Daemon\Process\Master::getInstance(); swoole_event_add($process->pipe, function ($pipe) use($process, $objMaster) { $objMaster->dispatch($process); }); }
protected function _stats($package) { $arrWorkers = unserialize($package); if (!is_array($arrWorkers) || empty($arrWorkers)) { return; } $total = 0; $arrRet = array(); foreach ($arrWorkers as $pid) { $taskNum = \Daemon\Library\Ipc\Shared::getCurrentTaskNumByKey($pid); $arrRet["w_{$pid}"] = $taskNum; $total += $taskNum; } $arrRet['total'] = $total; $flow = \Daemon\Library\Ipc\Shared::getMaxTaskNumAtomic()->get(); $arrRet['flow'] = $flow; $driveConf = $this->_objAha->getConfig()->get('aha', 'drive'); $maxProcessNum = intval($driveConf['max_process_num']); if ($flow > $total) { $arrRet['MONITOR1'] = "FLOW_OVER_FLOW_TOTAL"; } if ($flow >= $maxProcessNum) { $arrRet['MONITOR2'] = "FLOW_OVER_FLOW_MAX_PROCESS_NUM"; } Log::statsLog()->debug($arrRet); $average = $this->_flowPredict($flow); if ($average <= 0) { foreach ($arrWorkers as $pid) { \Daemon\Library\Ipc\Shared::setCurrentTaskTable($pid, array('taskNum' => 0)); } } }