diff --git a/bot/__init__.py b/bot/__init__.py index da55106..44289e0 100644 --- a/bot/__init__.py +++ b/bot/__init__.py @@ -5,7 +5,7 @@ from .config import Telegram, LOGGER_CONFIG_JSON dictConfig(LOGGER_CONFIG_JSON) -version = 1.0 +version = 1.1 logger = getLogger('bot') TelegramBot = Client( @@ -16,4 +16,4 @@ TelegramBot = Client( plugins={"root": "bot/plugins"}, workers = Telegram.BOT_WORKERS, max_concurrent_transmissions=1000 -) \ No newline at end of file +) diff --git a/bot/__main__.py b/bot/__main__.py index 86c5c32..ba9f106 100644 --- a/bot/__main__.py +++ b/bot/__main__.py @@ -1,7 +1,7 @@ from bot import TelegramBot, logger -from bot.server import server +from bot.server import run_server if __name__ == '__main__': logger.info('Initializing...') - TelegramBot.loop.create_task(server.serve()) - TelegramBot.run() \ No newline at end of file + TelegramBot.loop.create_task(run_server()) + TelegramBot.run() diff --git a/bot/config.py b/bot/config.py index 774ffa0..8ce66d7 100644 --- a/bot/config.py +++ b/bot/config.py @@ -37,11 +37,11 @@ LOGGER_CONFIG_JSON = { } }, 'loggers': { - 'uvicorn': { + 'hypercorn': { 'level': 'INFO', 'handlers': ['file_handler', 'stream_handler'] }, - 'uvicorn.error': { + 'hypercorn.error': { 'level': 'WARNING', 'handlers': ['file_handler', 'stream_handler'] }, @@ -50,4 +50,4 @@ LOGGER_CONFIG_JSON = { 'handlers': ['file_handler', 'stream_handler'] } } -} \ No newline at end of file +} diff --git a/bot/server/__init__.py b/bot/server/__init__.py index f60047a..9d52220 100644 --- a/bot/server/__init__.py +++ b/bot/server/__init__.py @@ -1,11 +1,12 @@ from quart import Quart -from uvicorn import Config, Server as UvicornServer +from hypercorn import Config +from hypercorn.asyncio import serve from logging import getLogger from bot.config import Server, LOGGER_CONFIG_JSON from . import main, error -logger = getLogger('uvicorn') +logger = getLogger('hypercorn') instance = Quart(__name__) @instance.before_serving @@ -20,11 +21,9 @@ instance.register_error_handler(404, error.not_found) instance.register_error_handler(405, error.invalid_method) instance.register_error_handler(error.HTTPError, error.http_error) -server = UvicornServer( - Config( - app = instance, - host = Server.BIND_ADDRESS, - port = Server.PORT, - log_config = LOGGER_CONFIG_JSON - ) -) \ No newline at end of file +async def run_server(): + config = Config() + config.bind = [f'{Server.BIND_ADDRESS}:{Server.PORT}'] + config.logconfig_dict = LOGGER_CONFIG_JSON + + await serve(instance, config) diff --git a/bot/server/templates/player.html b/bot/server/templates/player.html index 93bd1e3..f09d15d 100644 --- a/bot/server/templates/player.html +++ b/bot/server/templates/player.html @@ -1,4 +1,3 @@ - @@ -104,7 +103,7 @@