-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontrol.py
60 lines (42 loc) · 1.1 KB
/
control.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
49
50
51
52
53
54
55
56
57
58
59
60
#* * * * * python3 /var/www/html/control.py &
import os
import sys
import json
import time
import traceback
sys.path.append("/var/www/html/lib/")
from helper import *
import helper as h
file_name = os.path.basename(__file__)
try:
def start_main():
log(INFO, "main calistir")
cmd = "python3 "+h.app_base_path+"main.py &"
command_async(cmd)
def control_main():
temp = command("ps -aux | grep python | grep main.py")
log(INFO, "ps list: " + temp)
if temp == None or temp == "":
log(ERROR, "ps list alinamadi")
control = False
temp = temp.split("\n")
for i in range(len(temp)):
if len(temp[i]) == 0:
continue
try:
log(INFO, "index: " + str(temp[i].index(h.app_base_path+"main.py")))
control = True
except Exception as e:
t = None
if control == False:
log_and_run(start_main)
def run():
log_and_run(control_main)
#Ana Fonksiyon
if __name__ == "__main__":
preload(file_name, online = False)
log_and_run(run)
log_and_run(endload)
except Exception as e:
fn = os.path.basename(__file__)
root_ex(fn, e)