|
@@ -37,8 +37,8 @@ class HttpServerSettelement
|
|
|
$this->dbpooleconfig = GlobConfigs::getKey('pgsqlpoole');
|
|
$this->dbpooleconfig = GlobConfigs::getKey('pgsqlpoole');
|
|
|
$this->redisonfig = GlobConfigs::getKey('redis');
|
|
$this->redisonfig = GlobConfigs::getKey('redis');
|
|
|
|
|
|
|
|
- $taskWorkingNum = new \swoole\Atomic();
|
|
|
|
|
- $this->httpserver->taskWorkingNum = $taskWorkingNum;
|
|
|
|
|
|
|
+ $this->httpserver->account = new \swoole\Atomic();
|
|
|
|
|
+ $this->httpserver->taskWorkingNum = new \swoole\Atomic();
|
|
|
|
|
|
|
|
$this->httpserver->on('request', array($this, 'OnRequest'));
|
|
$this->httpserver->on('request', array($this, 'OnRequest'));
|
|
|
$this->httpserver->on('WorkerStart', array($this, 'onWorkerStart'));
|
|
$this->httpserver->on('WorkerStart', array($this, 'onWorkerStart'));
|
|
@@ -63,6 +63,19 @@ class HttpServerSettelement
|
|
|
if (!$serv->taskworker) {
|
|
if (!$serv->taskworker) {
|
|
|
$this->InitDb();
|
|
$this->InitDb();
|
|
|
}
|
|
}
|
|
|
|
|
+ if ($serv->worker_id == 0) {
|
|
|
|
|
+ \Swoole\Timer::tick(60000, function () {
|
|
|
|
|
+ $this->logRunStatus();
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private function logRunStatus()
|
|
|
|
|
+ {
|
|
|
|
|
+ echo date('Y-m-d H:i:s')." 总请求数:" . $this->httpserver->account->get() . ' 运行任务数:' . $this->httpserver->taskWorkingNum->get();
|
|
|
|
|
+ echo $this->httpserver->worker_id . " 内存使用量:" . (memory_get_usage() / 1000) . 'k 峰值:' . (memory_get_peak_usage() / 1000) . "k\n";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -75,8 +88,11 @@ class HttpServerSettelement
|
|
|
$request_uri = substr($request->server['request_uri'], 1);
|
|
$request_uri = substr($request->server['request_uri'], 1);
|
|
|
$urls = ['WinFail', 'Settelement'];
|
|
$urls = ['WinFail', 'Settelement'];
|
|
|
|
|
|
|
|
|
|
+ $this->httpserver->account->add();
|
|
|
|
|
+
|
|
|
echo "现在任务数:" . $this->httpserver->taskWorkingNum->get() . "\n";
|
|
echo "现在任务数:" . $this->httpserver->taskWorkingNum->get() . "\n";
|
|
|
|
|
|
|
|
|
|
+
|
|
|
if (!in_array($request_uri, $urls)) {
|
|
if (!in_array($request_uri, $urls)) {
|
|
|
$data = Response::generate('', 0, '', '无效的url');
|
|
$data = Response::generate('', 0, '', '无效的url');
|
|
|
$response->end($data);
|
|
$response->end($data);
|
|
@@ -130,6 +146,8 @@ class HttpServerSettelement
|
|
|
//胜负计算
|
|
//胜负计算
|
|
|
private function doWinFailse($request, $response, $paras)
|
|
private function doWinFailse($request, $response, $paras)
|
|
|
{
|
|
{
|
|
|
|
|
+ $this->httpserver->taskWorkingNum->add();
|
|
|
|
|
+
|
|
|
$logic_obj = new WinfailLogic();
|
|
$logic_obj = new WinfailLogic();
|
|
|
$notice = isset($paras['noticeid']) ? $paras['noticeid'] : 0;
|
|
$notice = isset($paras['noticeid']) ? $paras['noticeid'] : 0;
|
|
|
$id = intval($notice);
|
|
$id = intval($notice);
|
|
@@ -178,12 +196,17 @@ class HttpServerSettelement
|
|
|
$response->end($data);
|
|
$response->end($data);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ $this->httpserver->taskWorkingNum->sub();
|
|
|
|
|
+
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
private function doSettelementIntoRedis($request, $response, $paras)
|
|
private function doSettelementIntoRedis($request, $response, $paras)
|
|
|
{
|
|
{
|
|
|
|
|
+ $this->httpserver->taskWorkingNum->add();
|
|
|
|
|
+
|
|
|
try {
|
|
try {
|
|
|
list($order_ids, $bettype, $settype, $game_code, $match_id, $change_status) = $this->requestpara($request, $response, $paras);
|
|
list($order_ids, $bettype, $settype, $game_code, $match_id, $change_status) = $this->requestpara($request, $response, $paras);
|
|
|
|
|
|
|
@@ -230,14 +253,16 @@ class HttpServerSettelement
|
|
|
LABRETURN:
|
|
LABRETURN:
|
|
|
$data = Response::generate('', 1, ['cost' => (microtime(true) - $request->server['request_time_float'])], 'succes ');
|
|
$data = Response::generate('', 1, ['cost' => (microtime(true) - $request->server['request_time_float'])], 'succes ');
|
|
|
$response->end($data);
|
|
$response->end($data);
|
|
|
- return;
|
|
|
|
|
|
|
+
|
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
|
|
|
|
|
|
$data = Response::generate('', 10, '', $e->getMessage() . '--' . $e->getFile() . '--' . $e->getLine());
|
|
$data = Response::generate('', 10, '', $e->getMessage() . '--' . $e->getFile() . '--' . $e->getLine());
|
|
|
$response->end($data);
|
|
$response->end($data);
|
|
|
unset($data);
|
|
unset($data);
|
|
|
- return;
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ $this->httpserver->taskWorkingNum->sub();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private function requestpara($request, $response, $paras)
|
|
private function requestpara($request, $response, $paras)
|