Merge branch 'master' of vcs.bingo-boom.ru:difrex/surok

This commit is contained in:
Difrex 2016-08-08 10:14:05 +03:00
commit 4b2000c451

View File

@ -20,6 +20,7 @@ args = parser.parse_args()
if args.config: if args.config:
surok_conf = args.config surok_conf = args.config
# Read config file
f = open(surok_conf, 'r') f = open(surok_conf, 'r')
conf = json.loads(f.read()) conf = json.loads(f.read())
print(conf) print(conf)
@ -27,12 +28,14 @@ f.close()
# Get app configurations # Get app configurations
# Return list of patches to app discovery configuration
def get_configs(): def get_configs():
confs = [f for f in listdir(conf['confd']) if isfile( join(conf['confd'], f) )] confs = [f for f in listdir(conf['confd']) if isfile( join(conf['confd'], f) )]
return confs return confs
# Get Surok App configuration # Get Surok App configuration
# Read app conf from file and return dict
def load_app_conf(app): def load_app_conf(app):
f = open( conf['confd'] + '/' + app ) f = open( conf['confd'] + '/' + app )
c = json.loads( f.read() ) c = json.loads( f.read() )
@ -42,6 +45,11 @@ def load_app_conf(app):
# Main loop # Main loop
###########
# Bad hack for detect first run
# On host system set it to False
# TODO: put it to config
first = True first = True
while 1: while 1:
confs = get_configs() confs = get_configs()
@ -56,6 +64,7 @@ while 1:
"conf_name": app_conf['conf_name'] "conf_name": app_conf['conf_name']
} }
# Generate config from template
service_conf = gen(my, app_conf['template']) service_conf = gen(my, app_conf['template'])
stdout, first = reload_conf(service_conf, app_conf, first) stdout, first = reload_conf(service_conf, app_conf, first)