-
Notifications
You must be signed in to change notification settings - Fork 14
/
config.py
58 lines (44 loc) · 1.62 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
#!/usr/bin/env python
# coding: utf-8
import os
import sys
from apscheduler.jobstores.mongodb import MongoDBJobStore
from dotenv import find_dotenv, load_dotenv
reload(sys)
sys.setdefaultencoding('utf-8')
class BaseConfig(object):
WTF_CSRF_ENABLED = True
class ProductionConfig(BaseConfig):
if not os.getenv("MONGO_IP"):
load_dotenv(find_dotenv("config.env"))
ACCOUNT = os.getenv("ACCOUNT", "admin")
PASSWORD = os.getenv("PASSWORD", "admin")
MONGO_IP = os.getenv("MONGO_IP", "127.0.0.1")
MONGO_PORT = int(os.getenv("MONGO_PORT", 27017))
MONGO_USER = os.getenv("MONGO_USER", "scan")
MONGO_PWD = os.getenv("MONGO_PWD", "")
MONGO_DB_NAME = os.getenv("MONGO_DB_NAME", "portscan")
REDIS_IP = os.getenv("REDIS_IP", "127.0.0.1")
REDIS_PORT = os.getenv("REDIS_PORT", "6379")
REDIS_PWD = os.getenv("REDIS_PWD", "")
JOBS = []
if MONGO_PWD and MONGO_USER:
SCHEDULER_JOBSTORES = {
'default': MongoDBJobStore(database='apscheduler', collection='beholder_jobs',
host='mongodb://%s:%s@%s:%s/' % (
MONGO_USER, MONGO_PWD, MONGO_IP, MONGO_PORT))
}
else:
SCHEDULER_JOBSTORES = {
'default': MongoDBJobStore(database='apscheduler', collection='beholder_jobs',host=MONGO_IP, port=MONGO_PORT)
}
SCHEDULER_EXECUTORS = {
'default': {'type': 'threadpool', 'max_workers': 20}
}
SCHEDULER_JOB_DEFAULTS = {
'coalesce': True,
'max_instances': 3
}
SCHEDULER_API_ENABLED = True
if __name__ == '__main__':
ProductionConfig()