-
Notifications
You must be signed in to change notification settings - Fork 0
/
restart.py
48 lines (38 loc) · 1.33 KB
/
restart.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import os
import threading
import time
def startprgm(command, delay=0):
try:
time.sleep(delay)
os.system(command)
except:
print("Restart exception")
print('Stop: Clock and Messenger')
try:
t = threading.Thread(target=startprgm("sudo kill -9 $(ps ax | grep 'startup.py' | fgrep -v grep | awk '{ print $1 }')"))
t.start()
except:
print('Failed: kill startup.py')
try:
t = threading.Thread(target=startprgm("sudo kill -9 $(ps ax | grep 'LED_clock.py' | fgrep -v grep | awk '{ print $1 }')"))
t.start()
except:
print('Failed: kill Clock')
try:
t = threading.Thread(target=startprgm("sudo kill -9 $(ps ax | grep 'messenger.py' | fgrep -v grep | awk '{ print $1 }')"))
t.start()
except:
print('Failed: kill messenger')
try:
t = threading.Thread(target=startprgm("sudo kill -9 $(ps ax | grep 'watchdog.py' | fgrep -v grep | awk '{ print $1 }')"))
t.start()
except:
print('Failed: kill watchdog')
print('Start: Clock and Messenger')
t = threading.Thread(target=startprgm("sudo -H nohup python3 /home/pi/startup.py >/dev/null &"))
t.start()
try:
t = threading.Thread(target=startprgm("sudo kill -9 $(ps ax | grep 'restart.py' | fgrep -v grep | awk '{ print $1 }')", 10))
t.start()
except:
print('Failed: kill restart.py')