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

Method stop_project

class/projectModel/javaModel.py:2512–2549  ·  view source on GitHub ↗

@name 停止项目 @author hwliang<2021-08-09> @param get { project_name: string<项目名称> } @return dict

(self, get)

Source from the content-addressed store, hash-verified

2510 return sorted(all_pids)
2511
2512 def stop_project(self, get):
2513 ''&#x27;
2514 @name 停止项目
2515 @author hwliang<2021-08-09>
2516 @param get<dict_obj>{
2517 project_name: string<项目名称>
2518 }
2519 @return dict
2520 ''&#x27;
2521 project_info = self.get_project_find(get.project_name.strip())
2522 if not project_info: return public.returnMsg(False, '项目不存在')
2523
2524 project_find = self.get_project_find(get.project_name)
2525 if project_find['edate'] != "0000-00-00" and project_find['edate'] < datetime.datetime.today().strftime("%Y-%m-%d"):
2526 return public.return_error('当前项目已过期,请重新设置项目到期时间')
2527
2528 if project_info['project_config']['java_type'] == 'springboot':
2529 # pid_file = "{}/{}.pid".format(self._springboot_pid_path,get.project_name)
2530 pid_file = project_info['project_config']['pids']
2531 if not os.path.exists(pid_file): return public.returnMsg(False, '项目未启动')
2532 try:
2533 pid = int(public.readFile(pid_file))
2534 except:
2535 return public.returnMsg(False, '项目未启动')
2536 pids = self.get_project_pids(pid = pid)
2537 if not pids: return public.returnMsg(False, '项目未启动')
2538 self.kill_pids(pids = pids)
2539 if os.path.exists(pid_file): os.remove(pid_file)
2540 self.stop_by_user(project_info["id"])
2541 return public.returnMsg(True, '停止成功')
2542 if project_info['project_config']['java_type'] == 'duli':
2543 get.domain = project_info['name']
2544 get.type = 'stop'
2545 return self.pendent_tomcat_start(get)
2546 if project_info['project_config']['java_type'] == 'neizhi':
2547 get.version = project_info['project_config']['tomcat_version']
2548 get.type = 'stop'
2549 return self.start_tomcat(get)
2550
2551 def restart_project(self, get):
2552 ''&#x27;

Callers 7

restart_projectMethod · 0.95
fix_projectMethod · 0.95
remove_projectMethod · 0.95
modify_project_duliMethod · 0.95
change_log_pathMethod · 0.95

Calls 10

get_project_findMethod · 0.95
get_project_pidsMethod · 0.95
kill_pidsMethod · 0.95
pendent_tomcat_startMethod · 0.95
start_tomcatMethod · 0.95
returnMsgMethod · 0.80
readFileMethod · 0.80
existsMethod · 0.45
removeMethod · 0.45
stop_by_userMethod · 0.45

Tested by

no test coverage detected