Changes conf settings to lowercase
This commit is contained in:
parent
93e568ca21
commit
74aae9222d
6 changed files with 32 additions and 32 deletions
|
@ -1,17 +1,17 @@
|
|||
{
|
||||
"PATH": {
|
||||
"DATABASE": "database/default.db",
|
||||
"ERROR_LOG": "logs/error.log",
|
||||
"DEBUG_LOG": "logs/debug.log",
|
||||
"SERVER_LOG": "logs/server.log"
|
||||
"path": {
|
||||
"database": "database/default.db",
|
||||
"error_log": "logs/error.log",
|
||||
"debug_log": "logs/debug.log",
|
||||
"server_log": "logs/server.log"
|
||||
},
|
||||
"LOGGING": {
|
||||
"FORMAT": "%(asctime)s | %(levelname)s | %(name)s | %(module)s.%(funcName)s:%(lineno)d | %(message)s",
|
||||
"AIOHTTP_FORMAT": "%(asctime)s | %(levelname)s | %(name)s | %(message)s",
|
||||
"DATEFMT": "%Y-%m-%d %H:%M:%S"
|
||||
"logging": {
|
||||
"format": "%(asctime)s | %(levelname)s | %(name)s | %(module)s.%(funcName)s:%(lineno)d | %(message)s",
|
||||
"aiohttp_format": "%(asctime)s | %(levelname)s | %(name)s | %(message)s",
|
||||
"datefmt": "%Y-%m-%d %H:%M:%S"
|
||||
},
|
||||
"HOST": "localhost",
|
||||
"PORT": 5921,
|
||||
"BACKUP_INT": 3600,
|
||||
"LBRYNET": "http://localhost:5279"
|
||||
"host": "localhost",
|
||||
"port": 5921,
|
||||
"backup_int": 3600,
|
||||
"lbrynet": "http://localhost:5279"
|
||||
}
|
16
src/main.py
16
src/main.py
|
@ -13,12 +13,12 @@ def config_logging_from_settings(conf):
|
|||
"disable_existing_loggers": False,
|
||||
"formatters": {
|
||||
"standard": {
|
||||
"format": conf['LOGGING']['FORMAT'],
|
||||
"datefmt": conf['LOGGING']['DATEFMT']
|
||||
"format": conf['logging']['format'],
|
||||
"datefmt": conf['logging']['datefmt']
|
||||
},
|
||||
"aiohttp": {
|
||||
"format": conf['LOGGING']['AIOHTTP_FORMAT'],
|
||||
"datefmt": conf['LOGGING']['DATEFMT']
|
||||
"format": conf['logging']['aiohttp_format'],
|
||||
"datefmt": conf['logging']['datefmt']
|
||||
}
|
||||
},
|
||||
"handlers": {
|
||||
|
@ -32,7 +32,7 @@ def config_logging_from_settings(conf):
|
|||
"level": "DEBUG",
|
||||
"formatter": "standard",
|
||||
"class": "logging.handlers.RotatingFileHandler",
|
||||
"filename": conf['PATH']['DEBUG_LOG'],
|
||||
"filename": conf['path']['debug_log'],
|
||||
"maxBytes": 10485760,
|
||||
"backupCount": 5
|
||||
},
|
||||
|
@ -40,7 +40,7 @@ def config_logging_from_settings(conf):
|
|||
"level": "ERROR",
|
||||
"formatter": "standard",
|
||||
"class": "logging.handlers.RotatingFileHandler",
|
||||
"filename": conf['PATH']['ERROR_LOG'],
|
||||
"filename": conf['path']['error_log'],
|
||||
"maxBytes": 10485760,
|
||||
"backupCount": 5
|
||||
},
|
||||
|
@ -48,7 +48,7 @@ def config_logging_from_settings(conf):
|
|||
"level": "NOTSET",
|
||||
"formatter": "aiohttp",
|
||||
"class": "logging.handlers.RotatingFileHandler",
|
||||
"filename": conf['PATH']['SERVER_LOG'],
|
||||
"filename": conf['path']['server_log'],
|
||||
"maxBytes": 10485760,
|
||||
"backupCount": 5
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ def main(argv=None):
|
|||
args = parser.parse_args(argv)
|
||||
config_logging_from_settings(config)
|
||||
if args.port:
|
||||
config['PORT'] = args.port
|
||||
config['port'] = args.port
|
||||
config_logging_from_settings(config)
|
||||
run_app(config)
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ async def setup_db_schema(app):
|
|||
async def database_backup_routine(app):
|
||||
try:
|
||||
while True:
|
||||
await asyncio.sleep(app['config']['BACKUP_INT'])
|
||||
await asyncio.sleep(app['config']['backup_int'])
|
||||
with app['reader'] as conn:
|
||||
logger.debug('backing up database')
|
||||
backup_database(conn, app['backup'])
|
||||
|
@ -59,14 +59,14 @@ async def close_comment_scheduler(app):
|
|||
|
||||
class CommentDaemon:
|
||||
def __init__(self, config, db_file=None, backup=None, **kwargs):
|
||||
self.config = config
|
||||
app = web.Application()
|
||||
app['config'] = config
|
||||
self.config = app['config']
|
||||
if db_file:
|
||||
app['db_path'] = db_file
|
||||
app['backup'] = backup
|
||||
else:
|
||||
app['db_path'] = config['PATH']['DATABASE']
|
||||
app['db_path'] = config['path']['database']
|
||||
app['backup'] = backup or (app['db_path'] + '.backup')
|
||||
app.on_startup.append(setup_db_schema)
|
||||
app.on_startup.append(start_background_tasks)
|
||||
|
@ -83,16 +83,16 @@ class CommentDaemon:
|
|||
self.app_site = None
|
||||
|
||||
async def start(self, host=None, port=None):
|
||||
self.app['START_TIME'] = time.time()
|
||||
self.app['start_time'] = time.time()
|
||||
self.app_runner = web.AppRunner(self.app)
|
||||
await self.app_runner.setup()
|
||||
self.app_site = web.TCPSite(
|
||||
runner=self.app_runner,
|
||||
host=host or self.config['HOST'],
|
||||
port=port or self.config['PORT'],
|
||||
host=host or self.config['host'],
|
||||
port=port or self.config['port'],
|
||||
)
|
||||
await self.app_site.start()
|
||||
logger.info(f'Comment Server is running on {self.config["HOST"]}:{self.config["PORT"]}')
|
||||
logger.info(f'Comment Server is running on {self.config["host"]}:{self.config["port"]}')
|
||||
|
||||
async def stop(self):
|
||||
await self.app_runner.shutdown()
|
||||
|
|
|
@ -129,5 +129,5 @@ async def get_api_endpoint(request: web.Request):
|
|||
return web.json_response({
|
||||
'text': 'OK',
|
||||
'is_running': True,
|
||||
'uptime': int(time.time()) - request.app['START_TIME']
|
||||
'uptime': int(time.time()) - request.app['start_time']
|
||||
})
|
||||
|
|
|
@ -44,7 +44,7 @@ def make_error(error, exc=None) -> dict:
|
|||
async def request_lbrynet(app, method, **params):
|
||||
body = {'method': method, 'params': {**params}}
|
||||
try:
|
||||
async with aiohttp.request('POST', app['config']['LBRYNET'], json=body) as req:
|
||||
async with aiohttp.request('POST', app['config']['lbrynet'], json=body) as req:
|
||||
try:
|
||||
resp = await req.json()
|
||||
except JSONDecodeError as jde:
|
||||
|
|
|
@ -9,8 +9,8 @@ config_path = root_dir / 'config' / 'conf.json'
|
|||
def get_config(filepath):
|
||||
with open(filepath, 'r') as cfile:
|
||||
conf = json.load(cfile)
|
||||
for key, path in conf['PATH'].items():
|
||||
conf['PATH'][key] = str(root_dir / path)
|
||||
for key, path in conf['path'].items():
|
||||
conf['path'][key] = str(root_dir / path)
|
||||
return conf
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue