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

Method get_project_pids

mod/project/nodejs/base.py:484–516  ·  view source on GitHub ↗

@name 获取项目进程pid列表 @author hwliang<2021-08-10> @param pid: string<项目pid> @return list

(self, get=None, pid=None)

Source from the content-addressed store, hash-verified

482 return False
483
484 def get_project_pids(self, get=None, pid=None):
485 ''&#x27;
486 @name 获取项目进程pid列表
487 @author hwliang<2021-08-10>
488 @param pid: string<项目pid>
489 @return list
490 ''&#x27;
491 if get: pid = int(get.pid)
492 if not self._pids: self._pids = psutil.pids()
493 project_pids = []
494
495 for i in self._pids:
496 try:
497 p = psutil.Process(i)
498 if p.status() == "zombie":
499 continue
500 if p.ppid() == pid:
501 if i in project_pids:
502 continue
503 project_pids.append(i)
504 except:
505 continue
506
507 other_pids = []
508 for i in project_pids:
509 other_pids += self.get_project_pids(pid=i)
510 if os.path.exists('/proc/{}'.format(pid)):
511 project_pids.append(pid)
512
513 all_pids = list(set(project_pids + other_pids))
514 if not all_pids:
515 all_pids = self.get_other_pids(pid)
516 return sorted(all_pids)
517
518 def get_other_pids(self, pid):
519 ''&#x27;

Callers 2

get_project_run_stateMethod · 0.95
get_project_load_infoMethod · 0.95

Calls 6

get_other_pidsMethod · 0.95
setFunction · 0.50
statusMethod · 0.45
appendMethod · 0.45
existsMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected