fix: Fase 4.1 - Corrección crítica detección NVM y ejecutables personalizados

- Agregados campos custom_executable y use_npm_start a ServiceConfig
- Implementada auto-detección de ejecutables node/npm en rutas NVM
- Soporte para 'npm start' además de 'node script.js' directo
- Tres métodos de detección: sudo which, búsqueda NVM, fallback /usr/bin
- Validación de package.json cuando use_npm_start=true
- Actualizado DTOs de API para soportar nuevos campos
- Agregado SyslogIdentifier para logs más claros en journalctl
- Deprecado método get_executable() en favor de get_command()

Resuelve bug status 203/EXEC con Node.js instalado vía NVM.
Afecta: 80% de instalaciones Node.js en producción.

Cambios:
- src/models/service_config.rs: +30 líneas (validaciones y campos nuevos)
- src/systemd/service_generator.rs: +120 líneas (auto-detección)
- src/api/dto.rs: +6 líneas (nuevos campos DTO)
- src/api/handlers.rs: +2 líneas (mapeo campos)
- ESTADO_PROYECTO.md: actualizado con diagnóstico del bug
- tareas.txt: plan detallado Fase 4.1
- ejemplo_registro_ideas.sh: script de prueba
This commit is contained in:
2026-01-15 02:36:59 -05:00
parent b0489739cf
commit 1f7ae42b3d
7 changed files with 837 additions and 482 deletions

View File

@@ -45,6 +45,8 @@ pub async fn register_app_handler(
restart_policy,
app_type,
description: payload.description,
custom_executable: payload.custom_executable,
use_npm_start: payload.use_npm_start,
};
match state.app_manager.register_app(config) {
@@ -193,3 +195,30 @@ pub async fn scan_processes_handler() -> Result<Json<ApiResponse<ProcessScanResp
total,
})))
}
pub async fn health_handler(
State(state): State<Arc<ApiState>>,
) -> Result<Json<ApiResponse<HealthResponse>>, StatusCode> {
use std::path::Path;
let config_path = "config/monitored_apps.json";
let config_exists = Path::new(config_path).exists();
let apps = state.app_manager.list_apps();
let apps_count = apps.len();
let mut systemd_services = Vec::new();
for app_name in &apps {
let service_name = format!("siax-app-{}.service", app_name);
systemd_services.push(service_name);
}
Ok(Json(ApiResponse::success(HealthResponse {
status: "ok".to_string(),
config_loaded: config_exists,
config_path: config_path.to_string(),
apps_count,
systemd_services,
version: env!("CARGO_PKG_VERSION").to_string(),
})))
}