|
@@ -21,6 +21,7 @@ template = jinja_env.get_template('nginx.tpl')
|
21
|
21
|
fetcher = etcdlib.Connection(args.etcd_host, args.etcd_port, args.etcd_prefix)
|
22
|
22
|
|
23
|
23
|
while True:
|
|
24
|
+ wroteConfig = False;
|
24
|
25
|
services = []
|
25
|
26
|
domains = {k: v.split(',') for k, v in fetcher.get_label('com.chameth.vhost').items()}
|
26
|
27
|
protocols = fetcher.get_label('com.chameth.proxy.protocol')
|
|
@@ -40,9 +41,11 @@ while True:
|
40
|
41
|
'default': container in defaults,
|
41
|
42
|
})
|
42
|
43
|
|
43
|
|
- with open('/nginx-config/vhosts.conf', 'w') as f:
|
44
|
|
- print('Writing vhosts.conf...', flush=True)
|
45
|
|
- f.write(template.render(services=services))
|
|
44
|
+ if wroteConfig or len(services) > 0 or not os.path.isfile('/nginx-config/vhosts.conf'):
|
|
45
|
+ with open('/nginx-config/vhosts.conf', 'w') as f:
|
|
46
|
+ print('Writing vhosts.conf...', flush=True)
|
|
47
|
+ f.write(template.render(services=services))
|
|
48
|
+ wroteConfig = True;
|
46
|
49
|
|
47
|
50
|
print('Done writing config.', flush=True)
|
48
|
51
|
|