aboutsummaryrefslogtreecommitdiffstats
path: root/crates/asist-app/src/supervisor.rs
diff options
context:
space:
mode:
authorelvis <elvis@claros.ar>2026-09-26 20:20:19 -0300
committerelvis <elvis@claros.ar>2026-09-26 20:20:19 -0300
commit8518a63f55153e7f45fd49ad6caff5555f4e374f (patch)
tree636684eea3fa6f35d78282ab95eb687ef49154af /crates/asist-app/src/supervisor.rs
parent69de76dc9cbedc6092d1e5ce84094a8030de1470 (diff)
downloadasist-p-8518a63f55153e7f45fd49ad6caff5555f4e374f.tar.gz
asist-p-8518a63f55153e7f45fd49ad6caff5555f4e374f.zip
Translate code, comments, logs and terminal UI to English; add English README; rename scriptsHEADmain
Diffstat (limited to 'crates/asist-app/src/supervisor.rs')
-rw-r--r--crates/asist-app/src/supervisor.rs78
1 files changed, 39 insertions, 39 deletions
diff --git a/crates/asist-app/src/supervisor.rs b/crates/asist-app/src/supervisor.rs
index 17360da..75f6a7e 100644
--- a/crates/asist-app/src/supervisor.rs
+++ b/crates/asist-app/src/supervisor.rs
@@ -1,9 +1,9 @@
-//! Arranque y parada de los servidores locales.
+//! Starting and stopping the local servers.
//!
-//! El asistente puede levantar `llama-server` y `tts-server` él mismo, para
-//! que ponerlo en marcha sea un solo comando. Los procesos se lanzan en su
-//! propio grupo y se paran con SIGTERM antes de recurrir a SIGKILL: matar en
-//! seco a llama-server deja la GPU ocupada hasta que el driver la recupera.
+//! The assistant can start `llama-server` and `tts-server` itself, so getting
+//! it running is a single command. The processes are launched in their own
+//! group and stopped with SIGTERM before resorting to SIGKILL: killing
+//! llama-server outright leaves the GPU busy until the driver recovers it.
use std::path::Path;
use std::process::{Child, Command, Stdio};
@@ -32,23 +32,23 @@ impl Supervisor {
})
}
- /// Lanza los servidores que la configuración pida y que no estén ya arriba.
+ /// Starts the servers the configuration asks for that are not already up.
///
- /// Reutilizar uno que ya escucha es deliberado: durante el desarrollo se
- /// reinicia el asistente muchas veces y volver a cargar los modelos
- /// cuesta más de un minuto.
+ /// Reusing one that is already listening is deliberate: during development
+ /// the assistant is restarted many times, and reloading the models takes
+ /// more than a minute.
pub fn start(&mut self, config: &Config, llm_up: bool, tts_up: bool) -> Result<()> {
if !config.supervisor.manage {
return Ok(());
}
if llm_up {
- tracing::info!(target: "supervisor", "llama-server ya está escuchando, se reutiliza");
+ tracing::info!(target: "supervisor", "llama-server is already listening, reusing it");
} else {
let command = llama_command(&config.supervisor.llama, config)?;
self.spawn("llama-server", command)?;
}
if tts_up {
- tracing::info!(target: "supervisor", "tts-server ya está escuchando, se reutiliza");
+ tracing::info!(target: "supervisor", "tts-server is already listening, reusing it");
} else {
let command = tts_command(&config.supervisor.tts, config)?;
self.spawn("tts-server", command)?;
@@ -61,9 +61,9 @@ impl Supervisor {
let log = std::fs::File::create(&log_path)?;
let errors = log.try_clone()?;
- // La salida va al fichero: los modelos escupen cientos de líneas y
- // taparían la transcripción en pantalla. Cuando algo falla, el
- // mensaje de error apunta aquí.
+ // Output goes to the file: the models spit out hundreds of lines and
+ // would bury the on-screen transcription. When something fails, the
+ // error message points here.
command
.stdin(Stdio::null())
.stdout(Stdio::from(log))
@@ -71,22 +71,22 @@ impl Supervisor {
let child = command.spawn().map_err(|e| {
Error::Config(format!(
- "no se pudo lanzar {name} ({:?}): {e}",
+ "could not start {name} ({:?}): {e}",
command.get_program()
))
})?;
tracing::info!(
target: "supervisor",
- proceso = name,
+ process = name,
pid = child.id(),
- registro = %log_path.display(),
+ registered = %log_path.display(),
"lanzado"
);
self.children.push(Managed { name, child });
Ok(())
}
- /// Comprueba si alguno se ha muerto solo, y devuelve su nombre.
+ /// Checks whether any of them died on its own, and returns its name.
pub fn crashed(&mut self) -> Option<(&'static str, Option<i32>)> {
for managed in &mut self.children {
if let Ok(Some(status)) = managed.child.try_wait() {
@@ -100,7 +100,7 @@ impl Supervisor {
self.log_dir.join(format!("{name}.log"))
}
- /// Para todo lo lanzado. SIGTERM primero para que liberen la GPU.
+ /// Stops everything that was launched. SIGTERM first so they release the GPU.
pub fn shutdown(&mut self) {
for managed in &mut self.children {
terminate(&mut managed.child, managed.name);
@@ -119,8 +119,8 @@ fn terminate(child: &mut Child, name: &str) {
if matches!(child.try_wait(), Ok(Some(_))) {
return;
}
- // SIGTERM directo: `Child::kill` manda SIGKILL, que no da al servidor
- // ocasión de soltar la memoria de la GPU.
+ // Direct SIGTERM: `Child::kill` sends SIGKILL, which gives the server no
+ // chance to release GPU memory.
#[cfg(unix)]
unsafe {
libc_kill(child.id() as i32, 15);
@@ -132,22 +132,22 @@ fn terminate(child: &mut Child, name: &str) {
while Instant::now() < deadline {
match child.try_wait() {
Ok(Some(_)) => {
- tracing::info!(target: "supervisor", proceso = name, "detenido");
+ tracing::info!(target: "supervisor", proc_handle = name, "detenido");
return;
}
Ok(None) => std::thread::sleep(Duration::from_millis(100)),
Err(_) => break,
}
}
- tracing::warn!(target: "supervisor", proceso = name, "no respondió a SIGTERM, se fuerza");
+ tracing::warn!(target: "supervisor", proc_handle = name, "did not respond to SIGTERM, forcing it");
let _ = child.kill();
let _ = child.wait();
}
#[cfg(unix)]
unsafe fn libc_kill(pid: i32, signal: i32) {
- // Se declara aquí el único símbolo de libc que hace falta, en vez de
- // arrastrar el crate entero por una llamada.
+ // The only libc symbol needed is declared here, instead of pulling in
+ // the whole crate for one call.
unsafe extern "C" {
fn kill(pid: i32, sig: i32) -> i32;
}
@@ -161,15 +161,15 @@ fn require(path: &Path, what: &str) -> Result<()> {
return Ok(());
}
Err(Error::Config(format!(
- "falta {what}: {}. Ejecuta scripts/bootstrap.sh para compilar los \
- motores y enlazar los modelos",
+ "missing {what}: {}. Run scripts/bootstrap.sh to build the \
+ engines and link the models",
path.display()
)))
}
fn llama_command(process: &LlamaProcess, config: &Config) -> Result<Command> {
- require(&process.binary, "el binario de llama-server")?;
- require(&process.model, "el modelo del LLM")?;
+ require(&process.binary, "the llama-server binary")?;
+ require(&process.model, "the LLM model")?;
let mut command = Command::new(&process.binary);
command
@@ -183,8 +183,8 @@ fn llama_command(process: &LlamaProcess, config: &Config) -> Result<Command> {
if process.mmproj.exists() {
command.arg("--mmproj").arg(&process.mmproj);
}
- // Sin esto, la plantilla del modelo abre <think> y no lo cierra nunca: el
- // asistente se pasa entre 7 y 9 s razonando antes de la primera palabra.
+ // Without this, the model template opens <think> and never closes it: the
+ // assistant spends 7 to 9 s reasoning before the first word.
if process.chat_template.exists() {
command
.arg("--jinja")
@@ -193,9 +193,9 @@ fn llama_command(process: &LlamaProcess, config: &Config) -> Result<Command> {
} else {
tracing::warn!(
target: "supervisor",
- ruta = %process.chat_template.display(),
- "no está la plantilla sin razonamiento: el modelo tardará varios \
- segundos en empezar a hablar"
+ path = %process.chat_template.display(),
+ "the no-reasoning template is missing: the model will take several \
+ seconds to start talking"
);
}
command.args(&process.extra_args);
@@ -203,9 +203,9 @@ fn llama_command(process: &LlamaProcess, config: &Config) -> Result<Command> {
}
fn tts_command(process: &TtsProcess, config: &Config) -> Result<Command> {
- require(&process.binary, "el binario de tts-server")?;
- require(&process.model, "el modelo hablante del TTS")?;
- require(&process.codec, "el codec del TTS")?;
+ require(&process.binary, "the tts-server binary")?;
+ require(&process.model, "the TTS talker model")?;
+ require(&process.codec, "the TTS codec")?;
let mut command = Command::new(&process.binary);
command
@@ -219,8 +219,8 @@ fn tts_command(process: &TtsProcess, config: &Config) -> Result<Command> {
.arg(config.tts.port.to_string())
.arg("--lang")
.arg(&config.tts.language)
- // El ajuste con más efecto de todo el sistema: de fábrica son 24 s, que
- // en la práctica significa no devolver nada hasta terminar la frase.
+ // The single most effective setting in the system: the stock value is
+ // 24 s, which in practice means returning nothing until the sentence ends.
.arg("--codec-chunk-dur")
.arg(process.codec_chunk_dur.to_string());
command.args(&process.extra_args);