ping(); } else { //有数据 $buffer = stream_socket_recvfrom($s, DGRAM_MAXSIZE, 0, $from); if (empty($buffer)) { debug_log("Transfer@{$addr} stream_socket_recvfrom() got empty data from {$from}", 'WARNING', LOG_NAME); continue; } $data = json_decode($buffer, true); if (!$data || !is_array($data) || count($data) < 1) { continue; } $async->pushJob($data); } } } catch (RedisException $e) { debug_log("Transfer@{$addr} catched an RedisException:" . $e->getMessage(), 'EXCEPTION', LOG_NAME); } fclose($s); unlink($lockFile); /** * 信号处理函数 * @param int $signo 信号 */ function sig_handle($signo) { global $quit, $restart; switch ($signo) { //退出 case SIGTERM: $quit = true; break; //重启 case SIGUSR1: $restart = true; break; } }