forked from 9inevolt/OverRustle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathangelthump.py
More file actions
26 lines (22 loc) · 732 Bytes
/
Copy pathangelthump.py
File metadata and controls
26 lines (22 loc) · 732 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from urllib2 import Request, urlopen, URLError, HTTPError
from subprocess import call
import threading
import datetime
import time
def plsDontKillYourself():
req = Request('http://overrustle.com/strims')
threading.Timer(60.0, plsDontKillYourself).start()
try:
response = urlopen(req)
except URLError as e:
if hasattr(e, 'reason'):
print 'ERROR: unable to connect. Restarting Nginx + PHP5-FPM..'
print 'Reason: ', e.reason
call(["service", "nginx", "restart"])
time.sleep(1)
call(["service", "php5-fpm", "restart"])
elif hasattr(e, 'code'):
print 'ERROR: PHP stopped responding. Restarting PHP5-FPM...'
print 'Error code: ', e.code
call(["service", "php5-fpm", "restart"])
plsDontKillYourself()