worker service 매물 등록 및 redis 다운시 처리
This commit is contained in:
@@ -3,6 +3,7 @@ namespace App\Controllers;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\common\LoginModel;
|
||||
use CodeIgniter\Session\Handlers\DatabaseHandler;
|
||||
|
||||
class Login extends BaseController
|
||||
{
|
||||
@@ -13,6 +14,37 @@ class Login extends BaseController
|
||||
$this->loginModel = new LoginModel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Redis 폴백 상태 체크 (세션이 DatabaseHandler로 동작 중인지)
|
||||
*/
|
||||
private function getSystemStatus(): array
|
||||
{
|
||||
$status = [
|
||||
'redis_fallback' => false,
|
||||
'warning_message' => ''
|
||||
];
|
||||
|
||||
// Session 설정에서 현재 드라이버 확인
|
||||
$sessionConfig = config('Session');
|
||||
if ($sessionConfig->driver === DatabaseHandler::class) {
|
||||
$status['redis_fallback'] = true;
|
||||
$status['warning_message'] = '세션 서버(Redis) 장애로 임시 모드로 운영 중입니다. 시스템 관리자에게 문의하세요.';
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON 응답에 시스템 상태 추가
|
||||
*/
|
||||
private function jsonResponse(array $data): \CodeIgniter\HTTP\ResponseInterface
|
||||
{
|
||||
$systemStatus = $this->getSystemStatus();
|
||||
$data['system'] = $systemStatus;
|
||||
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
|
||||
public function index(): string
|
||||
{
|
||||
$user_id = get_cookie('save_id');
|
||||
@@ -59,7 +91,7 @@ class Login extends BaseController
|
||||
];
|
||||
|
||||
if (!$this->validate($rules)) {
|
||||
return $this->response->setJSON([
|
||||
return $this->jsonResponse([
|
||||
'code' => '1',
|
||||
'errors' => $this->validator->getErrors()
|
||||
]);
|
||||
@@ -82,7 +114,7 @@ class Login extends BaseController
|
||||
|
||||
$this->loginModel->insertUserLog($logs);
|
||||
|
||||
return $this->response->setJSON([
|
||||
return $this->jsonResponse([
|
||||
'code' => '1',
|
||||
'msg' => '존재하지 않는 아이디입니다.'
|
||||
]);
|
||||
@@ -96,7 +128,7 @@ class Login extends BaseController
|
||||
|
||||
$this->loginModel->insertUserLog($logs);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
return $this->jsonResponse([
|
||||
'code' => '1',
|
||||
'msg' => '잘못된 비밀번호 입니다.'
|
||||
]);
|
||||
@@ -135,7 +167,7 @@ class Login extends BaseController
|
||||
|
||||
$this->session->set($newdata);
|
||||
|
||||
return $this->response->setJSON([
|
||||
return $this->jsonResponse([
|
||||
'code' => '0',
|
||||
'msg' => 'success'
|
||||
]);
|
||||
@@ -148,7 +180,17 @@ class Login extends BaseController
|
||||
log_message('error', '[LOGIN ERROR] ' . $e->getMessage());
|
||||
log_message('error', $e->getTraceAsString());
|
||||
|
||||
return $this->response->setJSON([
|
||||
// 세션 관련 에러인지 확인
|
||||
$errorMessage = $e->getMessage();
|
||||
if (stripos($errorMessage, 'session') !== false ||
|
||||
stripos($errorMessage, 'redis') !== false) {
|
||||
return $this->jsonResponse([
|
||||
'code' => '8',
|
||||
'msg' => '세션 서비스 오류입니다. 시스템 관리자에게 문의해주세요.'
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->jsonResponse([
|
||||
'code' => '9',
|
||||
'msg' => '서버 내부 오류가 발생했습니다. 잠시 후 다시 시도해주세요.'
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user