(self)
| 111 | public.writeFile(pid_file, str(pid)) |
| 112 | |
| 113 | def read_pid(self) -> Optional[int]: |
| 114 | if not self.env: |
| 115 | raise RuntimeError('未设置环境') |
| 116 | pid_file = os.path.join(SERVICE_PATH, '{}/{}.pid'.format(self.env.project_name, self.name)) |
| 117 | if not os.path.isfile(pid_file): |
| 118 | return None |
| 119 | |
| 120 | res = None |
| 121 | try: |
| 122 | res = int(public.readFile(pid_file)) |
| 123 | except: |
| 124 | pass |
| 125 | if isinstance(res, int) and res > 0: |
| 126 | return res |
| 127 | return None |
| 128 | |
| 129 | @classmethod |
| 130 | def from_config(cls, config: dict, |
no test coverage detected