Merge pull request #9 from BelarusRazam/main

Some improvements to development process. Improve Docker compatibility.
This commit is contained in:
mihalin 2022-01-27 04:05:46 +03:00 committed by GitHub
commit bea77807af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View File

@ -24,3 +24,6 @@ WEBHOOK_PORT=8443
CUSTOM_CERT=true CUSTOM_CERT=true
REDIS_PATH=redis://redis REDIS_PATH=redis://redis
# Set log level, can be CRITICAL, ERROR, WARNING, INFO, DEBUG. By default it set to INFO.
LOGLEVEL=

View File

@ -1,6 +1,6 @@
from dotenv import load_dotenv from dotenv import load_dotenv
from abc import ABC from abc import ABC
import os import os, logging
from olgram.utils.crypto import Cryptor from olgram.utils.crypto import Cryptor
from functools import lru_cache from functools import lru_cache
@ -54,10 +54,6 @@ class ServerSettings(AbstractSettings):
def hook_port(cls) -> int: def hook_port(cls) -> int:
return int(cls._get_env("WEBHOOK_PORT")) return int(cls._get_env("WEBHOOK_PORT"))
@classmethod
def app_host(cls) -> str:
return "olgram"
@classmethod @classmethod
def app_port(cls) -> int: def app_port(cls) -> int:
return 80 return 80
@ -87,6 +83,7 @@ class ServerSettings(AbstractSettings):
def append_text(cls) -> str: def append_text(cls) -> str:
return "\n\nЭтот бот создан с помощью @OlgramBot" return "\n\nЭтот бот создан с помощью @OlgramBot"
logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO"))
class BotSettings(AbstractSettings): class BotSettings(AbstractSettings):
@classmethod @classmethod

View File

@ -65,5 +65,5 @@ def main():
runner = web.AppRunner(app) runner = web.AppRunner(app)
loop.run_until_complete(runner.setup()) loop.run_until_complete(runner.setup())
logger.info("Server initialization done") logger.info("Server initialization done")
site = web.TCPSite(runner, host=ServerSettings.app_host(), port=ServerSettings.app_port(), ssl_context=context) site = web.TCPSite(runner, port=ServerSettings.app_port(), ssl_context=context)
return site return site