Bug: catch excrption request to engine fail

CR: sonhh (fake)
This commit is contained in:
2021-08-26 16:51:36 +07:00
parent b207d54462
commit 14467d53b5
10 changed files with 124 additions and 79 deletions

View File

@@ -86,7 +86,7 @@ class ApiController extends Controller {
$ip = $server_ip->data;
if ($this->is_connected() && $logs) {
$device_id = \app\models\SyncUrl::findOne(['key_config' => 'device_id']);
$id_camera = 209;
$id_camera = 0;
if ($device_id)
$id_camera = intval($device_id->data);
$logsInfo = CaptureLogs::findOne($logs);
@@ -260,7 +260,7 @@ class ApiController extends Controller {
]);
$updating = \app\models\SyncUrl::findOne(['key_config' => 'updating']);
}
$currentCache = json_decode(file_get_contents("http://localhost:2305/current-cache"), true);
$currentCache = json_decode(@file_get_contents("http://localhost:2305/current-cache"), true);
if ($updating->data === "true") {
if ($currentCache['n_128'] == $currentCache['n_512']) {
$updating->data = "false";
@@ -295,12 +295,15 @@ class ApiController extends Controller {
foreach ($images as $k => $v) {
if (!isset($v['features512']) || (isset($v['features512']) && count($v['features512']) == 0)) {
$start = $this->getCurrentTime();
$features = json_decode(common::requestToEngine("/get-feature", [
$features = common::requestToEngine("/get-feature", [
"image_paths" => [
["url" => "/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $v['url'], "type" => "raw"]
],
"type" => "512"
]), true);
]);
if (!$features['status'])
return ["status" => false];
$features = json_decode($features['data'], true);
$finish = $this->getCurrentTime();
$temp[] = round(($finish - $start), 4);
$v['features512'] = $features['results'][0]['feature512'];
@@ -320,7 +323,7 @@ class ApiController extends Controller {
}
}
file_get_contents("http://localhost:2305/update-feature");
@file_get_contents("http://localhost:2305/update-feature");
$updating->data = "false";
$updating->save();
return ["status" => true];
@@ -334,7 +337,7 @@ class ApiController extends Controller {
if ($server_ip)
$ip = $server_ip->data;
$device_id = \app\models\SyncUrl::findOne(['key_config' => 'device_id']);
$id_camera = 209;
$id_camera = 0;
if ($device_id)
$id_camera = intval($device_id->data);
$ls = CaptureLogs::find()->andWhere(['sync_status' => null])->all();
@@ -400,7 +403,7 @@ class ApiController extends Controller {
}
public function actionCurrentCache() {
return file_get_contents("http://localhost:2305/current-cache");
return @file_get_contents("http://localhost:2305/current-cache");
}
public function actionSaveToken() {
@@ -504,14 +507,16 @@ class ApiController extends Controller {
}
public function actionCheckLogs() {
Yii::$app->response->format = "json";
$server_ip = \app\models\SyncUrl::findOne(['key_config' => 'server_api']);
$ip = "https://dev-dc.beetai.com";
if ($server_ip)
$ip = $server_ip->data;
$device_id = \app\models\SyncUrl::findOne(['key_config' => 'device_id']);
$id_camera = 209;
if ($device_id)
$id_camera = intval($device_id->data);
if (!$device_id)
return ["data" => "check logs fail"];
$id_camera = intval($device_id->data);
$datas = json_decode(file_get_contents($ip . "/api/model/get_log_model", false, stream_context_create([
'http' => [
@@ -562,9 +567,8 @@ class ApiController extends Controller {
])
]
]));
file_get_contents("http://localhost:2305/update-feature?total=" . ListManagement::find()->count());
@file_get_contents("http://localhost:2305/update-feature?total=" . ListManagement::find()->count());
}
Yii::$app->response->format = "json";
return ["data" => "check logs"];
}
@@ -597,12 +601,15 @@ class ApiController extends Controller {
if (!$this->resizeImg($img, $fileTarget)) {
file_put_contents($fileTarget, $img);
}
$features = json_decode(common::requestToEngine("/get-feature", [
$features = common::requestToEngine("/get-feature", [
"image_paths" => [
["url" => "/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $fileName, "type" => "raw"]
],
"type" => "128"
]), true);
]);
if (!$features['status'])
return false;
$features = json_decode($features['data'], true);
$ft[] = [
"serverKey" => $files_name,
"url" => $fileName,