Skip to content

Commit 439b325

Browse files
authored
Merge pull request #6 from telling-me/fix/mission
[🐛 fix: 미션 업데이트 백그라운드 처리 x 추가]
2 parents a580102 + abb88bb commit 439b325

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

scripts/deploy-prod.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
# src 디렉토리로 이동
4+
cd "$(dirname "$0")/../src" || exit
5+
6+
# 실행 중인 Gunicorn 프로세스 종료
7+
echo "Stopping Gunicorn..."
8+
killall gunicorn 2>/dev/null || echo "No Gunicorn processes found."
9+
10+
# 실행 중인 Celery 워커 프로세스 종료
11+
echo "Stopping Celery workers..."
12+
pkill -f "celery -A celery_worker worker" 2>/dev/null || echo "No Celery worker processes found."
13+
14+
# 새로운 Celery 워커 시작
15+
echo "Starting Celery workers..."
16+
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 &
17+
18+
# 새로운 Gunicorn 시작
19+
echo "Starting Gunicorn..."
20+
poetry run nohup gunicorn main:app --workers 2 --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000 >> gunicorn.log 2>&1 &
21+
22+
echo "Services restarted successfully."

src/app/v2/answers/models/answer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
from app.v2.answers.querys.answer_query import (
99
SELECT_ANSWER_BY_USER_UUID_QUERY,
1010
SELECT_ANSWER_COUNT_BY_USER_UUID_QUERY,
11-
SELECT_MOST_RECENT_ANSWER_BY_USER_UUID_QUERY,
1211
SELECT_ANSWER_COUNT_BY_USER_UUID_QUERY_V2,
12+
SELECT_MOST_RECENT_ANSWER_BY_USER_UUID_QUERY,
1313
)
1414
from app.v2.users.models.user import User
1515
from common.utils.query_executor import QueryExecutor

src/app/v2/missions/router.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
from fastapi import APIRouter
1+
from typing import Any
22

3+
from fastapi import APIRouter, Depends
4+
5+
from app.v2.missions.services.mission_service import MissionService
36
from core.configs.celery_settings import process_mission_in_background
47

58
router = APIRouter(prefix="/mission", tags=["Mission"])
@@ -8,3 +11,16 @@
811
@router.get("")
912
async def mission_handler(user_id: str) -> None:
1013
process_mission_in_background.delay(user_id)
14+
15+
16+
@router.get("/direct")
17+
async def mission_handler_direct(
18+
user_id: str,
19+
mission_service: MissionService = Depends(),
20+
) -> dict[str, Any]:
21+
await mission_service.update_mission_progress(user_id=user_id)
22+
return {
23+
"code": 200,
24+
"message": "success",
25+
"data": True,
26+
}

0 commit comments

Comments
 (0)