Created
June 5, 2019 11:51
-
-
Save berkayakcay/812d541054c32e955e9058e5d5f5c5ec to your computer and use it in GitHub Desktop.
Kill all process in supervisord
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment