diff --git a/scripts/deploy-prod.sh b/scripts/deploy-prod.sh new file mode 100644 index 0000000..2bd2668 --- /dev/null +++ b/scripts/deploy-prod.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# src 디렉토리로 이동 +cd "$(dirname "$0")/../src" || exit + +# 실행 중인 Gunicorn 프로세스 종료 +echo "Stopping Gunicorn..." +killall gunicorn 2>/dev/null || echo "No Gunicorn processes found." + +# 실행 중인 Celery 워커 프로세스 종료 +echo "Stopping Celery workers..." +pkill -f "celery -A celery_worker worker" 2>/dev/null || echo "No Celery worker processes found." + +# 새로운 Celery 워커 시작 +echo "Starting Celery workers..." +PYTHONPATH=$(pwd) /home/ubuntu/.cache/pypoetry/virtualenvs/tellingme-python-server-p3Rjg27q-py3.12/bin/python -m celery -A celery_worker worker --loglevel=info --concurrency=1 & + +# 새로운 Gunicorn 시작 +echo "Starting Gunicorn..." +poetry run nohup gunicorn main:app --workers 2 --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000 >> gunicorn.log 2>&1 & + +echo "Services restarted successfully." \ No newline at end of file diff --git a/src/app/v2/answers/models/answer.py b/src/app/v2/answers/models/answer.py index fccffdf..98188f3 100644 --- a/src/app/v2/answers/models/answer.py +++ b/src/app/v2/answers/models/answer.py @@ -8,8 +8,8 @@ from app.v2.answers.querys.answer_query import ( SELECT_ANSWER_BY_USER_UUID_QUERY, SELECT_ANSWER_COUNT_BY_USER_UUID_QUERY, - SELECT_MOST_RECENT_ANSWER_BY_USER_UUID_QUERY, SELECT_ANSWER_COUNT_BY_USER_UUID_QUERY_V2, + SELECT_MOST_RECENT_ANSWER_BY_USER_UUID_QUERY, ) from app.v2.users.models.user import User from common.utils.query_executor import QueryExecutor diff --git a/src/app/v2/missions/router.py b/src/app/v2/missions/router.py index 37564a8..da468cd 100644 --- a/src/app/v2/missions/router.py +++ b/src/app/v2/missions/router.py @@ -1,5 +1,8 @@ -from fastapi import APIRouter +from typing import Any +from fastapi import APIRouter, Depends + +from app.v2.missions.services.mission_service import MissionService from core.configs.celery_settings import process_mission_in_background router = APIRouter(prefix="/mission", tags=["Mission"]) @@ -8,3 +11,16 @@ @router.get("") async def mission_handler(user_id: str) -> None: process_mission_in_background.delay(user_id) + + +@router.get("/direct") +async def mission_handler_direct( + user_id: str, + mission_service: MissionService = Depends(), +) -> dict[str, Any]: + await mission_service.update_mission_progress(user_id=user_id) + return { + "code": 200, + "message": "success", + "data": True, + }