Created
September 6, 2012 14:38
-
-
Save myano/3656939 to your computer and use it in GitHub Desktop.
This file runs in a cronjob every minute to check if logger.py is currently an actively running process. One limitation to this is that if a netsplit occurs the process will still be running but the connection to the server might not exist anymore or the
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 | |
""" | |
Checks to see if loggy.py is running | |
""" | |
import os | |
import time | |
from subprocess import * | |
i = 0 | |
while i <= 59: | |
i += 1 | |
FLAG = False | |
pids = [pid for pid in os.listdir('/proc') if pid.isdigit()] | |
for pid in pids: | |
if os.path.exists('/proc/' + pid + '/cmdline'): | |
try: | |
f = open("/proc/%s/cmdline" % (pid), 'rb').read() | |
except: | |
continue | |
if "osuosc" in f: | |
FLAG = True | |
if FLAG == False: | |
pid = Popen(["/usr/bin/python", | |
"/var/www/yanovich.net/public/logs/loggy.py", | |
"loggyjr", | |
"irc://irc.freenode.net/osuosc", | |
"/var/www/yanovich.net/public/logs/", | |
"https://yanovich.net/logs/"]).pid | |
continue | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment