precommit-setup
This commit is contained in:
30
main.py
30
main.py
@@ -2,24 +2,23 @@ import os
|
||||
from importlib import import_module
|
||||
from os.path import exists
|
||||
|
||||
from granian import Granian
|
||||
|
||||
from ariadne import load_schema_from_path, make_executable_schema
|
||||
from ariadne.asgi import GraphQL
|
||||
from granian import Granian
|
||||
from granian.server import Interfaces
|
||||
from sentry_sdk.integrations.aiohttp import AioHttpIntegration
|
||||
from sentry_sdk.integrations.ariadne import AriadneIntegration
|
||||
from sentry_sdk.integrations.redis import RedisIntegration
|
||||
from starlette.applications import Starlette
|
||||
import asyncio
|
||||
|
||||
from services.core import CacheStorage
|
||||
from services.rediscache import redis
|
||||
from services.schema import resolvers
|
||||
from settings import DEV_SERVER_PID_FILE_NAME, MODE, SENTRY_DSN
|
||||
|
||||
from services.core import CacheStorage
|
||||
|
||||
import_module("resolvers")
|
||||
schema = make_executable_schema(load_schema_from_path("inbox.graphql"), resolvers) # type: ignore
|
||||
import_module('resolvers')
|
||||
schema = make_executable_schema(load_schema_from_path('inbox.graphql'), resolvers) # type: ignore
|
||||
|
||||
|
||||
async def start_up():
|
||||
@@ -28,9 +27,9 @@ async def start_up():
|
||||
|
||||
await CacheStorage.init()
|
||||
|
||||
if MODE == "dev":
|
||||
if MODE == 'dev':
|
||||
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()))
|
||||
else:
|
||||
# startup sentry monitoring services
|
||||
@@ -45,8 +44,8 @@ async def start_up():
|
||||
AioHttpIntegration(),
|
||||
],
|
||||
)
|
||||
except Exception as e:
|
||||
print("STARTUP FAILED")
|
||||
except Exception:
|
||||
print('STARTUP FAILED')
|
||||
import traceback
|
||||
|
||||
traceback.print_exc()
|
||||
@@ -57,12 +56,7 @@ async def shutdown():
|
||||
|
||||
|
||||
app = Starlette(debug=True, on_startup=[start_up], on_shutdown=[shutdown])
|
||||
app.mount("/", GraphQL(schema, debug=True))
|
||||
app.mount('/', GraphQL(schema, debug=True))
|
||||
|
||||
if __name__ == "__main__":
|
||||
Granian(
|
||||
target="main:app",
|
||||
port=8888,
|
||||
interface=Interfaces.ASGI,
|
||||
reload=True
|
||||
).serve()
|
||||
if __name__ == '__main__':
|
||||
Granian(target='main:app', port=8888, interface=Interfaces.ASGI, reload=True).serve()
|
||||
|
Reference in New Issue
Block a user