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

Method get_project_run_state

mod/project/php/php_asyncMod.py:1002–1051  ·  view source on GitHub ↗

@name 获取项目运行状态信息 @param sitename 项目名称 @return dict

(self, get)

Source from the content-addressed store, hash-verified

1000
1001 # 获取项目状态
1002 def get_project_run_state(self, get):
1003 '''
1004 @name 获取项目运行状态信息
1005 @param sitename<string> 项目名称
1006 @return dict
1007 ''&#x27;
1008 try:
1009 sitename = get.sitename.strip()
1010 result = {}
1011 project_info = self.get_project_find(sitename)
1012 res = RealServer().daemon_status(sitename)
1013 result['status'] = res['status']
1014 result['sitename'] = sitename
1015 result['is_power_on'] = int(project_info["project_config"]['is_power_on'])
1016 result['project_path'] = project_info['path'] # type : str
1017 result['project_cmd'] = project_info["project_config"].get('start_cmd', '')
1018 result['project_port'] = project_info['project_config']['port']
1019 if result['project_path'][-1] != "/":
1020 result['project_path'] += "/"
1021 result['site_run_path'] = DirTool().get_site_run_path(sitename).replace(result['project_path'].rstrip("/"), "")
1022 if not result['site_run_path']:
1023 result['site_run_path'] = "/"
1024 result['php_version'] = project_info['project_config']['php_version']
1025 result['run_user'] = project_info['project_config'].get('run_user', 'www')
1026 result['ps'] = project_info['ps']
1027 result['pid'] = RealServer().get_daemon_pid(sitename)["data"]
1028 if result['pid'] in [0, '0', ''] and result['status']:
1029 res = public.ExecShell("""ps -aux |grep "{}"|grep -v "grep"|awk '{{print $2}}'""".format(result['project_cmd']))[0]
1030 res = res.strip().split("\n")
1031 if res and len(res) >= 1:
1032 res.sort()
1033 result['pid'] = res[0]
1034 result['Listen'] = []
1035 if result['pid']:
1036 children = RealProcess().get_process_tree(result['pid'])["data"]
1037 for chi in children:
1038 for i in chi.get("connections", []):
1039 port = i.get("local_port", '')
1040 addr = i.get("local_addr", '')
1041 status = i.get("status", 'dasd')
1042 if addr == '0.0.0.0':
1043 addr = public.GetLocalIp()
1044 if port and addr and status.lower() == 'listen':
1045 result['Listen'].append((addr, port))
1046 result['Listen'] = list(set(result['Listen']))
1047
1048 return public.returnResult(True, data=result)
1049 except:
1050 public.print_log(traceback.format_exc())
1051 return public.returnResult(False, '获取项目状态失败')
1052
1053 # 修改项目运行状态
1054 def modify_project_run_state(self, get):

Callers 5

get_group_listMethod · 0.95
group_add_projectMethod · 0.95
group_remove_projectMethod · 0.95
start_groupsMethod · 0.95
get_service_pidMethod · 0.45

Calls 15

get_project_findMethod · 0.95
RealServerClass · 0.90
DirToolClass · 0.90
RealProcessClass · 0.90
get_daemon_pidMethod · 0.80
ExecShellMethod · 0.80
GetLocalIpMethod · 0.80
returnResultMethod · 0.80
setFunction · 0.50
daemon_statusMethod · 0.45
getMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected