Skip to content

Commit

Permalink
fix: failed 푸시 알람을 위한 celery firebase 초기화
Browse files Browse the repository at this point in the history
  • Loading branch information
leehjhjhj committed Aug 17, 2023
1 parent 31fa3a5 commit b84c7f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion hackathon/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

cred_path = config("FIRE_BASE_JSON_KEY_PATH")
cred = credentials.Certificate(cred_path)
firebase_admin.initialize_app(cred)
if not firebase_admin._apps:
firebase_admin.initialize_app(cred)

django_asgi_app = get_asgi_application()

Expand Down
8 changes: 8 additions & 0 deletions hackathon/celery.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import os
from celery import Celery
import firebase_admin
from firebase_admin import credentials
from decouple import config

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'hackathon.settings.prod')

Expand All @@ -8,6 +11,11 @@

app.autodiscover_tasks()

cred_path = config("FIRE_BASE_JSON_KEY_PATH")
cred = credentials.Certificate(cred_path)
if not firebase_admin._apps:
firebase_admin.initialize_app(cred)

#테스트할 때만 주석해제하고 실제로 배포할 때는 주석처리하기
#@app.task(bind=True, ignore_result=True)
#def debug_task(self):
Expand Down

0 comments on commit b84c7f3

Please sign in to comment.