3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-30 14:49:28 +01:00
PyLink/conf.py
James Lu f786242730 Support loading different config files from the command line
Closes #84. Logs, PID files, and relay DBs will name themselves differently for every instance, to prevent conflicts. The default is always config.yml.
2015-08-03 19:27:19 -07:00

20 lines
492 B
Python

import yaml
import sys
global confname
try:
# Get the config name from the command line, falling back to config.yml
# if not given.
fname = sys.argv[1]
confname = fname.split('.', 1)[0]
except IndexError:
# confname is used for logging and PID writing, so that each
# instance uses its own files. fname is the actual name of the file
# we load.
confname = 'pylink'
fname = 'config.yml'
with open(fname, 'r') as f:
global conf
conf = yaml.load(f)