/** * 柔性重启服务器 * @return boolean 重启成功返回true,否则返回false */ public function reload() { if (!ApiServer::isRun()) { ApiServerException::throwException('The Api Server is not running,Can not reload!', ApiServerException::ERROR_CODE_API_SERVER_IS_NOT_RUNNING); } $result = ApiClient::instance()->sendData(array('type' => 'server', 'action' => 'reload')); return $result == 1; }
/** * 获取一个数据库连接 * @param array $dbConfig * @return Ambigous <\Wx\Wxdb\DBPoolConnection, \Wx\Wxdb\DBConnection> */ private function getDb(array $dbConfig) { if (empty($this->db)) { if (empty($dbConfig['db'])) { ApiServerException::throwException('数据库配置错误', ApiServerException::ERROR_CODE_DB_ERROR); } if (isset($dbConfig['pool']) && $dbConfig['pool']) { $this->db = new DBPoolConnection($dbConfig['db']['dns'], $dbConfig['db']['username'], $dbConfig['db']['password'], $dbConfig['db']['charset'], isset($dbConfig['db']['options']) ? $dbConfig['db']['options'] : array()); } else { $this->db = new DBConnection($dbConfig['db']['dns'], $dbConfig['db']['username'], $dbConfig['db']['password'], $dbConfig['db']['charset'], isset($dbConfig['db']['options']) ? $dbConfig['db']['options'] : array()); } } return $this->db; }