1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-26 00:38:10 +00:00

Restore configuration live reload

Closes #94
This commit is contained in:
Julien Duponchelle 2015-03-17 10:21:52 +01:00
parent 2de817214f
commit 54bccb0628

View File

@ -92,6 +92,27 @@ class Config(object):
self._config = configparser.ConfigParser()
self.read_config()
self._watch_config_file()
def _watch_config_file(self):
asyncio.get_event_loop().call_later(1, self._check_config_file_change)
def _check_config_file_change(self):
"""
Check if configuration file has changed on the disk
"""
changed = False
for file in self._watched_files:
try:
if os.stat(file).st_mtime != self._watched_files[file]:
changed = True
except OSError:
continue
if changed:
self.read_config()
for section in self._override_config:
self.set_section_config(section, self._override_config[section])
self._watch_config_file()
def reload(self):
"""