Add kill.py

This commit is contained in:
Nathan Franklin 2019-08-16 09:47:13 -05:00
parent a2df8c85ef
commit 2b2129b652
1 changed files with 26 additions and 0 deletions

26
kill.py Executable file
View File

@ -0,0 +1,26 @@
#!/usr/bin/env 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()
write_stdout('This line kills supervisor: ' + line);
try:
pidfile = open('/var/run/supervisord.pid','r')
pid = int(pidfile.readline());
os.kill(pid, signal.SIGQUIT)
except Exception as e:
write_stdout('Could not kill supervisor: ' + e.strerror + '\n')
write_stdout('RESULT 2\nOK')
if __name__ == '__main__':
main()
import sys