MCPcopy Create free account
hub / github.com/cppla/ServerStatus / get_sergate_pid

Function get_sergate_pid

server/manage_api.py:209–230  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

207
208
209def get_sergate_pid():
210 try:
211 with open(SERGATE_PID_FILE, "r", encoding="utf-8") as f:
212 pid = int(f.read().strip())
213 os.kill(pid, 0)
214 return pid
215 except Exception:
216 pass
217 proc_dir = "/proc"
218 if not os.path.isdir(proc_dir):
219 return None
220 for name in os.listdir(proc_dir):
221 if not name.isdigit():
222 continue
223 try:
224 with open(os.path.join(proc_dir, name, "cmdline"), "rb") as f:
225 cmdline = f.read().replace(b"\x00", b" ").decode("utf-8", "ignore")
226 except Exception:
227 continue
228 if "sergate" in cmdline:
229 return int(name)
230 return None
231
232
233def signal_sergate(sig):

Callers 2

signal_sergateFunction · 0.85
routeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected