concierge/kill.py

37 lines
802 B
Python
Raw Normal View History

2020-04-27 10:09:07 +02:00
#!/usr/bin/env python
import sys
import os
import signal
from supervisor.childutils import listener
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 True:
headers, body = listener.wait(sys.stdin, sys.stdout)
body = dict([pair.split(":") for pair in body.split(" ")])
if body["groupname"] == "concierge":
2020-04-27 10:10:05 +02:00
try:
pidfile = open('/run/supervisor.pid', 'r')
pid = int(pidfile.readline())
os.kill(pid, signal.SIGQUIT)
except Exception as e:
write_stdout('could not kill supervisor: %s\n' % e.strerror)
2020-04-27 10:09:07 +02:00
write_stdout('RESULT 2\nOK')
if __name__ == '__main__':
2020-04-27 10:10:05 +02:00
main()