-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
87 lines (72 loc) · 3.16 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# This Python file uses the following encoding: utf-8
import os
from envparse import Env
basedir = os.path.abspath(os.path.dirname(__file__))
env = Env()
env_file = os.environ.get('ENV', 'dev') + ".env"
env_file_path = os.path.join(basedir, 'conf', '.env_files', env_file)
env.read_envfile(env_file_path)
def get_path(*parts):
return os.path.join(basedir, *parts)
class Config:
NAME = env.str("NAME", default="hello_world")
ENV = env.str("ENV", default="dev")
DEBUG = env.bool("DEBUG", default=True)
TESTING = env.bool("TESTING", default=False)
SECRET_KEY = env.str("FLASK_SECRET_KEY", default="secret_key")
# DB
POSTGRES_USER = env.str("POSTGRES_USER", default="")
POSTGRES_PASSWORD = env.str("POSTGRES_PASSWORD", default="")
POSTGRES_DB_HOST = env.str("POSTGRES_DB_HOST", default="localhost")
POSTGRES_DB_PORT = env.int("POSTGRES_DB_PORT", default=5433)
POSTGRES_DB = env.str("POSTGRES_DB", default="helloworld_db")
SQLALCHEMY_DATABASE_URI = "{schema}://{login}:{password}@{host}:{port}/{db_name}".format(
schema="postgresql+psycopg2",
login=POSTGRES_USER,
password=POSTGRES_PASSWORD,
host=POSTGRES_DB_HOST,
port=POSTGRES_DB_PORT,
db_name=POSTGRES_DB
)
SQLALCHEMY_ENGINE_OPTIONS = {
'pool_size': env.int("SQLALCHEMY_POOL_SIZE", default=5),
'max_overflow': env.int("SQLALCHEMY_MAX_OVERFLOW", default=2),
'pool_timeout': env.int("SQLALCHEMY_POOL_TIMEOUT", default=60),
}
SQLALCHEMY_ECHO = env.bool("SQLALCHEMY_ECHO", default=True)
SQLALCHEMY_TRACK_MODIFICATIONS = env.bool("SQLALCHEMY_TRACK_MODIFICATIONS", default=False)
RABBITMQ_URI = "{schema}://{login}:{password}@{host}:{port}/{vhost}".format(
schema="pyamqp",
login=env.str("RABBITMQ_DEFAULT_USER", default=""),
password=env.str("RABBITMQ_DEFAULT_PASS", default=""),
host=env.str("RABBITMQ_HOST", default="localhost"),
port=env.int("RABBITMQ_PORT", default=5672),
vhost=env.str("RABBITMQ_DEFAULT_VHOST", default='vhost'),
)
REDIS_URI = "{schema}://{login}:{password}@{host}:{port}/".format(
schema="redis",
login=env.str("REDIS_LOGIN", default=""),
password=env.str("REDIS_PASSWORD", default=""),
host=env.str("REDIS_HOST", default="localhost"),
port=env.int("REDIS_PORT", default=6379),
)
CELERY_CONFIG = dict(
broker_url=RABBITMQ_URI,
result_backend=REDIS_URI,
accept_content=["pickle", "json"],
task_serializer='pickle',
result_serializer='json',
task_ignore_result=False,
imports=('app_celery.periodic', ),
beat_schedule=(),
timezone="Europe/Moscow",
# Raise exc if task takes too long
task_soft_time_limit=env.int("CELERY_SOFT_TIME_LIMIT", default=5*60),
# Kill worker if task too long
task_time_limit=env.int("CELERY_TASK_TIME_LIMIT", default=10*60),
)
# EMAIL Reports Credentials
SMTP_LOGIN = env.str("SMTP_LOGIN", default="")
SMTP_PASS = env.str("SMTP_PASS", default="")
SMTP_SERVER = env.str("SMTP_SERVER", default="smtp.gmail.com")
SMTP_PORT = env.int("SMTP_PORT", default=587)