mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-10 07:34:06 -08:00
20 lines
521 B
Plaintext
20 lines
521 B
Plaintext
|
#!/usr/bin/env python
|
||
|
# A supervisor event listener which terminates supervisord if any of its child
|
||
|
# processes enter the FATAL state.
|
||
|
# https://stackoverflow.com/a/37527488/119527
|
||
|
import os
|
||
|
import signal
|
||
|
|
||
|
from supervisor import childutils
|
||
|
|
||
|
def main():
|
||
|
while True:
|
||
|
headers, payload = childutils.listener.wait()
|
||
|
childutils.listener.ok()
|
||
|
if headers['eventname'] != 'PROCESS_STATE_FATAL':
|
||
|
continue
|
||
|
os.kill(os.getppid(), signal.SIGTERM)
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
main()
|