viewed-fix
All checks were successful
deploy / deploy (push) Successful in 1m22s

This commit is contained in:
Untone 2023-12-22 12:09:24 +03:00
parent b502c581f7
commit 4e769332b7

20
main.py
View File

@ -16,21 +16,28 @@ from resolvers.webhook import WebhookEndpoint
from services.rediscache import redis from services.rediscache import redis
from services.schema import resolvers from services.schema import resolvers
from settings import DEV_SERVER_PID_FILE_NAME, MODE, SENTRY_DSN from settings import DEV_SERVER_PID_FILE_NAME, MODE, SENTRY_DSN
import asyncio
from services.viewed import ViewedStorage
import_module("resolvers") import_module("resolvers")
schema = make_executable_schema(load_schema_from_path("schemas/core.graphql"), resolvers) # type: ignore schema = make_executable_schema(load_schema_from_path("schemas/core.graphql"), resolvers) # type: ignore
async def start_up(): async def start_up():
if MODE == "development":
if exists(DEV_SERVER_PID_FILE_NAME):
await redis.connect() 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: with open(DEV_SERVER_PID_FILE_NAME, "w", encoding="utf-8") as f:
f.write(str(os.getpid())) f.write(str(os.getpid()))
else:
await redis.connect() if MODE == "production":
# sentry monitoring
try: try:
import sentry_sdk import sentry_sdk
@ -45,7 +52,6 @@ async def start_up():
AioHttpIntegration(), AioHttpIntegration(),
], ],
) )
except Exception as e: except Exception as e:
print("[sentry] init error") print("[sentry] init error")
print(e) print(e)