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

Method run_operation

mod/project/java/groupMod.py:414–438  ·  view source on GitHub ↗
(self, operation: str)

Source from the content-addressed store, hash-verified

412 # 运行一个Group相关的函数
413 # ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
414 def run_operation(self, operation: str) -> Optional[str]:
415 pid_file = "{}/{}.pid".format(Group.GROUP_TMP_DIR, self.group_id)
416
417 if operation not in ("start", "stop"):
418 return "指定的操作不存在"
419
420 try:
421 p = psutil.Process(public.readFile(pid_file))
422 if p.is_running():
423 return "操作运行中, 请等待上一个操作执行完成"
424 except:
425 pass
426
427 if os.path.exists(pid_file):
428 os.remove(pid_file)
429
430 self.build_run_sort(reverse=(operation == "stop"))
431 self.save_running_data()
432 panel_path = "/www/server/panel"
433 public.ExecShell(
434 "nohup {}/pyenv/bin/python3 {}/mod/project/java/group_script.py {} {} &> /tmp/group_script.log & \n"
435 "echo $! > {} ".format(
436 panel_path, panel_path, operation, self.group_id, pid_file)
437 )
438 return None
439
440 def build_run_sort(self, reverse=False) -> List[List[dict]]:
441 projects = self.config["projects"] # type: List[Dict[str, Union[int, str, dict]]]

Callers 2

start_groupMethod · 0.95
stop_groupMethod · 0.95

Calls 8

build_run_sortMethod · 0.95
save_running_dataMethod · 0.95
readFileMethod · 0.80
ExecShellMethod · 0.80
formatMethod · 0.45
is_runningMethod · 0.45
existsMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected