This commit is contained in:
parent
b502c581f7
commit
4e769332b7
20
main.py
20
main.py
|
@ -16,21 +16,28 @@ from resolvers.webhook import WebhookEndpoint
|
|||
from services.rediscache import redis
|
||||
from services.schema import resolvers
|
||||
from settings import DEV_SERVER_PID_FILE_NAME, MODE, SENTRY_DSN
|
||||
import asyncio
|
||||
from services.viewed import ViewedStorage
|
||||
|
||||
|
||||
import_module("resolvers")
|
||||
schema = make_executable_schema(load_schema_from_path("schemas/core.graphql"), resolvers) # type: ignore
|
||||
|
||||
|
||||
async def start_up():
|
||||
if MODE == "development":
|
||||
if exists(DEV_SERVER_PID_FILE_NAME):
|
||||
await redis.connect()
|
||||
return
|
||||
else:
|
||||
|
||||
views_stat_task = asyncio.create_task(ViewedStorage().worker())
|
||||
print(views_stat_task)
|
||||
|
||||
if MODE == "development":
|
||||
# pid file management
|
||||
if not exists(DEV_SERVER_PID_FILE_NAME):
|
||||
with open(DEV_SERVER_PID_FILE_NAME, "w", encoding="utf-8") as f:
|
||||
f.write(str(os.getpid()))
|
||||
else:
|
||||
await redis.connect()
|
||||
|
||||
if MODE == "production":
|
||||
# sentry monitoring
|
||||
try:
|
||||
import sentry_sdk
|
||||
|
||||
|
@ -45,7 +52,6 @@ async def start_up():
|
|||
AioHttpIntegration(),
|
||||
],
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
print("[sentry] init error")
|
||||
print(e)
|
||||
|
|
Loading…
Reference in New Issue
Block a user