initial commit

This commit is contained in:
2023-05-01 02:37:14 +03:00
commit 4a5dfbff3a
23 changed files with 3739 additions and 0 deletions

10
settings/.env.ci.runtests Normal file
View File

@@ -0,0 +1,10 @@
STAGE="runtests"
APP_HOST="0.0.0.0"
APP_PORT="8000"
POSTGRES_HOST="postgres"
POSTGRES_PORT="5432"
POSTGRES_DB="relevancer"
POSTGRES_USER="user"
POSTGRES_PASSWORD="postgrespwd"

View File

@@ -0,0 +1 @@
STAGE="runtests"

8
settings/.env.staging Normal file
View File

@@ -0,0 +1,8 @@
APP_HOST="0.0.0.0"
APP_PORT="8000"
POSTGRES_HOST="postgres"
POSTGRES_PORT="5432"
POSTGRES_DB="relevancer"
POSTGRES_USER="user"
POSTGRES_PASSWORD="postgrespwd"

22
settings/.env.template Normal file
View File

@@ -0,0 +1,22 @@
STAGE="dev"
APP_HOST="0.0.0.0"
APP_PORT="8000"
USER="web"
TELEGRAM_API_TOKEN="123456789:AABBCCDDEEFFaabbccddeeff-1234567890"
# webhook settings
WEBHOOK_HOST="https://mydomain.com"
WEBHOOK_PATH="/healthcheck"
# set to true to start with webhook. Else bot will start on polling method
START_WITH_WEBHOOK="false"
# quantity of workers for uvicorn
WORKERS_COUNT=1
# Enable uvicorn reloading
RELOAD="true"
DEBUG="true"

0
settings/__init__.py Normal file
View File

50
settings/config.py Normal file
View File

@@ -0,0 +1,50 @@
from os import environ
from pathlib import Path
from dotenv import load_dotenv
from pydantic import BaseSettings
BASE_DIR = Path(__file__).parent.parent
SHARED_DIR = BASE_DIR.resolve().joinpath('shared')
SHARED_DIR.mkdir(exist_ok=True)
SHARED_DIR.joinpath('logs').mkdir(exist_ok=True)
DIR_LOGS = SHARED_DIR.joinpath('logs')
env_path = f"{BASE_DIR}/settings/.env"
if environ.get("STAGE") == "runtests":
if "LOCALTEST" in environ:
env_path = f"{BASE_DIR}/settings/.env.local.runtests"
else:
env_path = f"{BASE_DIR}/settings/.env.ci.runtests"
load_dotenv(env_path, override=True)
class Settings(BaseSettings):
"""Application settings."""
PROJECT_NAME: str = "healthcheck bot"
APP_HOST: str = "0.0.0.0"
APP_PORT: int = 8082
STAGE: str = "dev"
DEBUG: bool = False
TELEGRAM_API_TOKEN: str = "123456789:AABBCCDDEEFFaabbccddeeff-1234567890"
START_WITH_WEBHOOK: bool = False
# webhook settings
WEBHOOK_HOST: str = "https://mydomain.com"
WEBHOOK_PATH: str = "/healthcheck"
# quantity of workers for uvicorn
WORKERS_COUNT: int = 1
# Enable uvicorn reloading
RELOAD: bool = False
class Config:
case_sensitive = True
def get_settings() -> Settings:
return Settings()