fix: Ollama-Adapter räumt die Prozessgruppe auch bei Zeitlimit und frühem Ende auf (#1165); Version 0.1.15-rc21
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GmHhg6k5Hxh8GpVW7od4Di
This commit is contained in:
@ -270,11 +270,16 @@ impl OllamaEngine {
|
||||
.spawn()
|
||||
.map_err(|e| AdapterError::Spawn(format!("{}: {e}", self.config.binary.display())))?;
|
||||
|
||||
// Nach dem Beenden liefert `child.id()` nichts mehr; der Gruppenführer hat die PID der Gruppe.
|
||||
let pgid = child.id();
|
||||
let timeout = Duration::from_secs(self.config.ready_timeout_secs);
|
||||
let started = Instant::now();
|
||||
loop {
|
||||
if let Ok(Some(status)) = child.try_wait() {
|
||||
tracing::warn!(exit_code = status.code(), "ollama serve endete beim Start");
|
||||
if let Some(pgid) = pgid {
|
||||
terminate_group(pgid, Duration::from_secs(5)).await;
|
||||
}
|
||||
return Err(AdapterError::ExitedEarly {
|
||||
code: status.code(),
|
||||
log_tail: log_tail(&log_path, 20),
|
||||
@ -290,6 +295,10 @@ impl OllamaEngine {
|
||||
);
|
||||
let _ = child.start_kill();
|
||||
let _ = child.wait().await;
|
||||
// Auch Prozesse der Gruppe beenden (am echten Dienst nachgestellt: sonst bleiben sie verwaist).
|
||||
if let Some(pgid) = pgid {
|
||||
terminate_group(pgid, Duration::from_secs(5)).await;
|
||||
}
|
||||
return Err(AdapterError::NotReady {
|
||||
seconds: self.config.ready_timeout_secs,
|
||||
log_tail: log_tail(&log_path, 20),
|
||||
@ -304,8 +313,11 @@ impl OllamaEngine {
|
||||
"ollama serve ist bereit"
|
||||
);
|
||||
// Mit `process_group(0)` ist die Gruppen-ID die PID des Servers.
|
||||
let pgid = child.id().unwrap_or(0);
|
||||
Ok(Server { child, port, pgid })
|
||||
Ok(Server {
|
||||
pgid: pgid.unwrap_or(0),
|
||||
child,
|
||||
port,
|
||||
})
|
||||
}
|
||||
|
||||
async fn get_text(&self, url: &str, timeout_secs: u64) -> Option<String> {
|
||||
|
||||
Reference in New Issue
Block a user