} echo $response; } else { //执行逻辑 $controller = new Controller($postRaw); $response = $controller->action(); //结果返回 if (!DEBUG) { Log::w(ob_get_contents()); ob_end_clean(); //清理缓冲 } echo $response; } } elseif (DEBUG === true) { Log::cancel(); $dbResult = false; switch (DB_TYPE) { case 'mysql': $dbResult = support\DbDeployer::initMysql(); break; /** 其他类型数据库暂不支持 case 'others' **/ /** 其他类型数据库暂不支持 case 'others' **/ default: $dbResult = support\DbDeployer::initMysql(); break; }
public function action() { if ($this->postClass == null) { return Response::EMPTY_RESPONSE; } //从排重缓存中获取超时缓存消息 $retry = 7; while ($retry--) { $memCache = $this->cacheController->getRetry($this->cacheController->keyRetry($this->postClass)); if (!empty($memCache)) { //返回字串执行结果 Log::cancel(); return $memCache; } elseif ($memCache === '') { //有键无值,首次执行还没结束,直接等待下一次请求 Log::cancel(); sleep(1); } else { break; } } if ($retry <= 0) { //超时等待下一次重连 return ''; } //在排重缓存中记录缓存值,防止第二次请求重新触发 $this->cacheController->putRetry($this->postClass['CreateTime'], $this->cacheController->keyRetry($this->postClass), ''); //在所有自动回复前hook if ($this->hook) { @$this->hook->onPreExecute($this->postClass); } $target = false; //先定空返回值 $phps = $this->getFromCache(); //针对有缓存情况执行,若[无缓存]或[缓存无效],返回$target==false $target = $this->ergodicPhps($phps); //没有缓存或缓存不符合(即旧缓存无效) if (empty($target)) { $list = $this->getFromList(); //提取所有php文件 if (is_array($phps)) { //有缓存但缓存无效 //在所有php文件中删除,避免重复检验 if (($listKey = array_search($phps[0], $list)) !== false) { unset($list[$listKey]); } } //执行所有遍历 $target = $this->ergodicPhps($list); } $this->callMessage($this->postClass); $result = $this->invokeTarget($target); $target = null; //在所有自动回复后hook if ($this->hook) { @$this->hook->onPostExecute($result); } //在排重缓存中记录已执行完成的结果值,在下次请求时直接返回 $this->cacheController->putRetry($this->postClass['CreateTime'], $this->cacheController->keyRetry($this->postClass), $result); Log::response($result); return $result; }