Addonに適用

This commit is contained in:
2026-02-12 18:52:55 +09:00
parent 0b6c31501e
commit a2131a962b
7 changed files with 225 additions and 7 deletions
+40 -5
View File
@@ -72,21 +72,56 @@ class InferenceClient:
cwd=root_dir,
text=True,
env=server_env,
stdout=subprocess.PIPE, # Capture stdout
stderr=subprocess.PIPE, # Capture stderr
preexec_fn=os.setsid, # Create new process group
)
# Wait for startup
for _ in range(20): # Wait up to 10 seconds
if self.is_server_running():
print("[FaceMask] Server started successfully")
return
# Check if process died
if self.server_process.poll() is not None:
raise RuntimeError(f"Server failed to start (rc={self.server_process.returncode})")
# Capture and display error output
try:
stdout, stderr = self.server_process.communicate(timeout=1)
except subprocess.TimeoutExpired:
stdout, stderr = "", ""
error_msg = f"Server failed to start (exit code: {self.server_process.returncode})"
print(f"[FaceMask] ERROR: {error_msg}")
if stdout and stdout.strip():
print("[FaceMask] Server stdout:")
print(stdout.strip())
if stderr and stderr.strip():
print("[FaceMask] Server stderr:")
print(stderr.strip())
self.server_process = None
raise RuntimeError(error_msg)
time.sleep(0.5)
# If we get here, startup timed out
# Try to capture any partial output
if self.server_process:
try:
# Non-blocking read with short timeout
stdout, stderr = self.server_process.communicate(timeout=0.1)
if stdout and stdout.strip():
print("[FaceMask] Server stdout (partial):")
print(stdout.strip())
if stderr and stderr.strip():
print("[FaceMask] Server stderr (partial):")
print(stderr.strip())
except subprocess.TimeoutExpired:
pass # Process still running but not responding
raise RuntimeError("Server startup timed out")
def stop_server(self):