Skip to content

Commit

Permalink
Merge pull request #1417 from chrismeyersfsu/fix-config_watcher
Browse files Browse the repository at this point in the history
invoke main() in config watcher script
  • Loading branch information
chrismeyersfsu authored Mar 1, 2018
2 parents 8c1ec37 + b69315f commit f907995
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tools/scripts/config-watcher
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,23 @@ def write_hash(f, h):


def main():
settings_file = "/etc/tower/settings.py"
hash_file = "/var/lib/awx/.configsha"

while 1:
rpc = childutils.getRPCInterface(os.environ)
headers, payload = childutils.listener.wait(sys.stdin, sys.stdout)
if not headers['eventname'].startswith('TICK'):
childutils.listener.ok(sys.stdout)
continue
try:
current_hash = hash("/etc/tower/settings.py")
current_hash = hash(settings_file)
except:
sys.stderr.write("Could not open settings.py, skipping config watcher")
childutils.listener.ok(sys.stdout)
continue
try:
if current_hash == last_hash("/var/lib/awx/.configsha"):
if current_hash == last_hash(hash_file):
childutils.listener.ok(sys.stdout)
continue
else:
Expand All @@ -51,8 +54,11 @@ def main():
sys.stderr.write('Restarting %s\n' % program)
rpc.supervisor.stopProcess(program)
rpc.supervisor.startProcess(program)

except:
sys.stderr.write("No previous hash found")
write_hash("/var/lib/awx/.configsha")

write_hash(hash_file, current_hash)
childutils.listener.ok(sys.stdout)

if __name__ == '__main__':
main()

0 comments on commit f907995

Please sign in to comment.