From 21db4c2272321adb34a8f3594d5b5cebbb97cdb5 Mon Sep 17 00:00:00 2001 From: Dmitry Afanasyev Date: Tue, 16 Aug 2022 12:57:56 +0300 Subject: [PATCH] changed to gunicorn --- app/main.py | 5 +++++ scripts/start-bot.sh | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index b7fa17c..92dbfb6 100644 --- a/app/main.py +++ b/app/main.py @@ -66,9 +66,14 @@ async def webhook(request: web.Request) -> web.Response: return web.Response(status=HTTPStatus.OK) +async def on_startup_gunicorn(app: web.Application) -> None: + await dispatcher.bot.set_webhook(WEBHOOK_URL) + + async def create_app() -> web.Application: application = web.Application() application.router.add_post('/', webhook) + application.on_startup.append(on_startup_gunicorn) return application diff --git a/scripts/start-bot.sh b/scripts/start-bot.sh index 8528b53..80bd6b2 100644 --- a/scripts/start-bot.sh +++ b/scripts/start-bot.sh @@ -4,4 +4,4 @@ echo "starting the bot" cd /opt/mosgortrans \ && source /home/balsh/.cache/pypoetry/virtualenvs/mosgortrans-3eZxMcY3-py3.10/bin/activate \ -&& gunicorn app.main:create_app --bind prod-server.lan:8084 --reload --worker-class aiohttp.GunicornWebWorker \ No newline at end of file +&& gunicorn app.main:create_app --bind prod-server.lan:8084 --worker-class aiohttp.GunicornWebWorker \ No newline at end of file