Created
June 13, 2017 10:02
-
-
Save t27/d2b514a90e74bc8588c5a6d31edab824 to your computer and use it in GitHub Desktop.
Run a command continously (Reloads a command/program if it crashes)
This file contains hidden or 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 signal | |
import sys | |
import os | |
import subprocess | |
process = 0 | |
if len(sys.argv[:])<2: | |
print "USAGE: python runner.py \"<your execution statement>\" \nQuotes are only necessary of you want to do redirection or something like that" | |
else: | |
while(True): | |
cmd = ' '.join(sys.argv[1:]) | |
print("Launching APP - " + cmd) | |
process = subprocess.Popen(cmd, shell=True) | |
process.communicate() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
Everything after runner.py will be executed indefinitely(until Ctrl-C is pressed). If the command ends/crashes, it will be reloaded.
sysout for the command will be sent to the parent scripts sysout