--config option and some PEP8 and comments
This commit is contained in:
parent
651ed3420c
commit
231de765d1
23
surok.py
23
surok.py
@ -8,8 +8,19 @@ from surok.templates import gen
|
|||||||
from surok.discovery import resolve
|
from surok.discovery import resolve
|
||||||
from surok.system import reload_conf
|
from surok.system import reload_conf
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
|
||||||
# Load base configurations
|
# Load base configurations
|
||||||
f = open('/etc/surok/conf/surok.json', 'r')
|
surok_conf = '/etc/surok/conf/surok.json'
|
||||||
|
|
||||||
|
# Command line arguments
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument('-c', '--config')
|
||||||
|
args = parser.parse_args()
|
||||||
|
if args.config:
|
||||||
|
surok_conf = args.config
|
||||||
|
|
||||||
|
f = open(surok_conf, 'r')
|
||||||
conf = json.loads(f.read())
|
conf = json.loads(f.read())
|
||||||
print(conf)
|
print(conf)
|
||||||
f.close()
|
f.close()
|
||||||
@ -35,8 +46,16 @@ while 1:
|
|||||||
confs = get_configs()
|
confs = get_configs()
|
||||||
for app in confs:
|
for app in confs:
|
||||||
app_conf = load_app_conf(app)
|
app_conf = load_app_conf(app)
|
||||||
|
|
||||||
|
# Resolve services
|
||||||
app_hosts = resolve(app_conf, conf)
|
app_hosts = resolve(app_conf, conf)
|
||||||
my = {'app': app_conf['name'], 'hosts': app_hosts}
|
|
||||||
|
# Populate my dictionary
|
||||||
|
my = {
|
||||||
|
'app': app_conf['name'],
|
||||||
|
'hosts': app_hosts
|
||||||
|
}
|
||||||
|
|
||||||
service_conf = gen(my, app_conf['template'])
|
service_conf = gen(my, app_conf['template'])
|
||||||
|
|
||||||
print( reload_conf(service_conf, app_conf) )
|
print( reload_conf(service_conf, app_conf) )
|
||||||
|
Loading…
Reference in New Issue
Block a user