mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 09:27:36 -02:30
fix up the config map watcher script
* invoke main() in config watcher script * correctly call hash update by passing the filename
This commit is contained in:
@@ -25,6 +25,9 @@ def write_hash(f, h):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
settings_file = "/etc/tower/settings.py"
|
||||||
|
hash_file = "/var/lib/awx/.configsha"
|
||||||
|
|
||||||
while 1:
|
while 1:
|
||||||
rpc = childutils.getRPCInterface(os.environ)
|
rpc = childutils.getRPCInterface(os.environ)
|
||||||
headers, payload = childutils.listener.wait(sys.stdin, sys.stdout)
|
headers, payload = childutils.listener.wait(sys.stdin, sys.stdout)
|
||||||
@@ -32,13 +35,13 @@ def main():
|
|||||||
childutils.listener.ok(sys.stdout)
|
childutils.listener.ok(sys.stdout)
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
current_hash = hash("/etc/tower/settings.py")
|
current_hash = hash(settings_file)
|
||||||
except:
|
except:
|
||||||
sys.stderr.write("Could not open settings.py, skipping config watcher")
|
sys.stderr.write("Could not open settings.py, skipping config watcher")
|
||||||
childutils.listener.ok(sys.stdout)
|
childutils.listener.ok(sys.stdout)
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
if current_hash == last_hash("/var/lib/awx/.configsha"):
|
if current_hash == last_hash(hash_file):
|
||||||
childutils.listener.ok(sys.stdout)
|
childutils.listener.ok(sys.stdout)
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
@@ -51,8 +54,11 @@ def main():
|
|||||||
sys.stderr.write('Restarting %s\n' % program)
|
sys.stderr.write('Restarting %s\n' % program)
|
||||||
rpc.supervisor.stopProcess(program)
|
rpc.supervisor.stopProcess(program)
|
||||||
rpc.supervisor.startProcess(program)
|
rpc.supervisor.startProcess(program)
|
||||||
|
|
||||||
except:
|
except:
|
||||||
sys.stderr.write("No previous hash found")
|
sys.stderr.write("No previous hash found")
|
||||||
write_hash("/var/lib/awx/.configsha")
|
|
||||||
|
write_hash(hash_file, current_hash)
|
||||||
childutils.listener.ok(sys.stdout)
|
childutils.listener.ok(sys.stdout)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user