Телеграм бот не стартует на webhook

При запуске(на VPS) бота выскакивает ошибка:

File "/home/myproject/myprojectenv/lib/python3.10/site-packages/gunicorn/workers/sync.py", line 179, in handle_request
respiter = self.wsgi(environ, resp.start_response)
File "/home/myproject/myprojectenv/lib/python3.10/site-packages/aiogram/utils/executor.py", line 99, in start_webhook
executor = set_webhook(dispatcher=dispatcher,
File "/home/myproject/myprojectenv/lib/python3.10/site-packages/aiogram/utils/executor.py", line 74, in set_webhook
executor = Executor(dispatcher, skip_updates=skip_updates, check_ip=check_ip, retry_after=retry_after,
File "/home/myproject/myprojectenv/lib/python3.10/site-packages/aiogram/utils/executor.py", line 155, in __init__  Bot.set_current(dispatcher.bot)
AttributeError: 'dict' object has no attribute 'bot'

webhook настроен как в https://docs.aiogram.dev/en/latest/examples/webhook_example.html

как устранить эту ошибку? Спасибо.

myproject.service

[Unit]
Description=Gunicorn instance to serve myproject
After=network.target

[Service]
User=root
Group=www-data
WorkingDirectory=/home/myproject
Environment="PATH=/home/myproject/myprojectenv/bin"
ExecStart=/home/myproject/myprojectenv/bin/gunicorn --workers 3 --bind unix:myproject.sock -m 007 wsgi:app

[Install]
WantedBy=multi-user.target

myproject

server {
    server_name d.ru www.d.ru;

    location / {
        include proxy_params;
        proxy_pass http://unix:/home/myproject/myproject.sock;
    }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/d.ru/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/d.ru/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}server {
    if ($host = www.d.ru) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = d.ru) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80;
    server_name d.ru www.d.ru;
    return 404; # managed by Certbot




}

wsgi.py

from aiogram.utils.executor import start_webhook as app

from config import WEBHOOK_PATH, WEBAPP_HOST, WEBAPP_PORT

from create_bot import dp

from myproject import on_startup, on_shutdown

if __name__ == "__main__":
    app(
        dispatcher=dp,
        webhook_path=WEBHOOK_PATH,
        on_startup=on_startup,
        on_shutdown=on_shutdown,
        skip_updates=True,
        host=WEBAPP_HOST,
        port=WEBAPP_PORT)

create_bot.py

from aiogram import Bot, Dispatcher
import config

bot = Bot(config.TOKEN_TELEGRAM)
dp = Dispatcher(bot)

myproject.py

from aiogram import Dispatcher
from aiogram.utils import executor
from config import WEBHOOK_URL, WEBHOOK_PATH, WEBAPP_HOST, WEBAPP_PORT
from create_bot import dp, bot
from handlers import register_handlers

register_handlers(dp)


async def on_startup(dispatcher: Dispatcher) -> None:
    await bot.delete_webhook()
    await bot.set_webhook(WEBHOOK_URL)


async def on_shutdown(dispatcher: Dispatcher) -> None:
    await bot.delete_webhook()
    await dp.storage.close()
    await dp.storage.wait_closed()


if __name__ == "__main__":
    executor.start_webhook(
        dispatcher=dp,
        webhook_path=WEBHOOK_PATH,
        on_startup=on_startup,
        on_shutdown=on_shutdown,
        skip_updates=True,
        host=WEBAPP_HOST,
        port=WEBAPP_PORT)

Ответы (0 шт):