DanielDent/cowhand

JSON end of input

Closed this issue · 1 comments

Regarding the JSON issue, I fixed the code based on your hint.

It is something like this:

    while True:
        time.sleep(30)
        with open('/prom-rancher-sd-data/rancher.json.temp', 'w') as config_file:
            print(json.dumps(get_monitoring_config(), indent=2),file=config_file)
        shutil.move('/prom-rancher-sd-data/rancher.json.temp','/prom-rancher-sd-data/rancher.json')

print was needed to add newline at end of json (probably it's working fine even without it) and shutil.move did the trick.

Best regards

Thank you.