1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 06:51:10 +03:00
awx/tools/scripts/failure-event-handler
Bill Nottingham 5d1346b956 Use AWX python interpreter for failure-event-handler.
python3 isn't in the normal path when using SCLs.
2019-04-29 20:32:50 -04:00

26 lines
635 B
Plaintext
Executable File

#!/usr/bin/awx-python
import sys
import os
import signal
def write_stdout(s):
sys.stdout.write(s)
sys.stdout.flush()
def write_stderr(s):
sys.stderr.write(s)
sys.stderr.flush()
def main():
while 1:
write_stdout('READY\n')
line = sys.stdin.readline()
headers = dict([ x.split(':') for x in line.split() ])
headers.update(dict([ x.split(':') for x in sys.stdin.read(int(headers['len'])).split()]))
if headers['eventname'] == 'PROCESS_STATE_FATAL':
os.kill(os.getppid(), signal.SIGTERM)
write_stdout('RESULT 2\nOK')
if __name__ == "__main__":
main()