scan(); while (true) { pcntl_signal_dispatch(); try { if ($this->_stop) break; $content = $worker->pop($queues, 1); if(is_array($content)) { $method = key($content); $arg = current($content); $argstr = json_encode($arg,JSON_UNESCAPED_UNICODE); Log::record("method={$method} args={$argstr}",Log::DEBUG); $result = $logic_queue->$method($arg); if ($result['code'] != 0) { Log::record("{$method} run error: {$result['msg']}",Log::ERR); } } } catch (Exception $e) { $err = $e->getMessage(); $code = $e->getCode(); Log::record("QueueDB pop err: code={$code} err={$err}",Log::DEBUG); break; } } } private function sig_handler($signo) { Log::record("queue quit at sig_handler.",Log::DEBUG); switch($signo) { case SIGINT: case SIGHUP: case SIGQUIT: case SIGTERM: $this->_stop = true; break; default: break; } } }