MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / PythonDaemons

Function PythonDaemons

script/project_daemon.py:78–107  ·  view source on GitHub ↗

@name Python 项目守护进程 @author baozi@bt.cn @time 2023-10-21

()

Source from the content-addressed store, hash-verified

76
77
78def PythonDaemons():
79 '''
80 @name Python 项目守护进程
81 @author baozi@bt.cn
82 @time 2023-10-21
83 '''
84 boot_time = psutil.boot_time()
85 now = time.time()
86 boot_start = int(now - boot_time) < 60 * 10
87 if public.M('sites').where('project_type=?', ('Python')).count() >= 1:
88 project_info = public.M('sites').where('project_type=?', ('Python')).select()
89 for i in project_info:
90 try:
91 import json
92 from projectModel import pythonModel
93
94 i['project_config'] = json.loads(i['project_config'])
95 if 'auto_run' in i['project_config'] and i['project_config']['auto_run'] in ["1", 1, True, "true"]:
96 python_obj = pythonModel.main()
97 if python_obj.get_project_run_state(project_name=i['name']):
98 continue
99 else:
100 if not python_obj.is_stop_by_user(i["id"]) or boot_start:
101 # 如果项目是在后台停止的,那么就不再启动
102 get = public.dict_obj()
103 get.name = i['name']
104 python_obj.StartProject(get)
105 public.WriteLog('守护进程', 'Python项目[{}]已经被守护进程启动'.format(i['name']))
106 except:
107 continue
108
109
110def NetDaemons():

Callers 1

project_daemon.pyFile · 0.85

Calls 11

timeMethod · 0.80
StartProjectMethod · 0.80
countMethod · 0.45
whereMethod · 0.45
MMethod · 0.45
selectMethod · 0.45
loadsMethod · 0.45
mainMethod · 0.45
get_project_run_stateMethod · 0.45
is_stop_by_userMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected