MCPcopy Create free account
hub / github.com/1jehuang/jcode / get_server_pid

Function get_server_pid

scripts/stress_test.py:60–83  ·  view source on GitHub ↗

Get the jcode server PID.

()

Source from the content-addressed store, hash-verified

58 sock.close()
59
60def get_server_pid():
61 """Get the jcode server PID."""
62 try:
63 result = subprocess.run(
64 ["lsof", "-U", "-a", "-c", "jcode"],
65 capture_output=True, text=True, timeout=5
66 )
67 for line in result.stdout.splitlines():
68 if "jcode.sock" in line and "LISTEN" in line:
69 parts = line.split()
70 return int(parts[1])
71 except:
72 pass
73
74 # Fallback: find the oldest jcode process (likely the server)
75 try:
76 result = subprocess.run(
77 ["pgrep", "-o", "jcode"], capture_output=True, text=True, timeout=5
78 )
79 if result.stdout.strip():
80 return int(result.stdout.strip().splitlines()[0])
81 except:
82 pass
83 return None
84
85def proc_stat(pid):
86 """Get process stats from /proc."""

Callers 1

stress_test.pyFile · 0.85

Calls 2

runMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected