--- name: systemd_install kind: function lang: go domain: infra version: "1.0.0" purity: impure signature: "func SystemdInstall(conn SSHConn, unitName, unitContent string) error" description: "Sube un unit file al host remoto, hace daemon-reload, enable y restart. Idempotente: reemplaza si el unit ya existe." tags: [systemd, install, deploy, service, remote] uses_functions: [ssh_exec_go_infra] uses_types: [ssh_conn_go_infra] returns: [] returns_optional: false error_type: "error_go_core" imports: [fmt] params: - name: conn desc: "conexión SSH al host remoto" - name: unitName desc: "nombre del unit sin extensión (ej: dag_engine)" - name: unitContent desc: "contenido completo del archivo .service (generado por SystemdGenerateUnit)" output: "nil si el unit se instaló y arrancó correctamente" tested: false tests: [] test_file_path: "" file_path: "functions/infra/systemd_install.go" --- ## Ejemplo ```go conn := SSHConn{Host: "192.168.1.100", User: "deploy"} unit := SystemdGenerateUnit("dag_engine", "/opt/apps/dag_engine/dag_engine", "/opt/apps/dag_engine", "deploy", nil) err := SystemdInstall(conn, "dag_engine", unit) ``` ## Notas Escribe el unit a un archivo temporal en /tmp y lo mueve con sudo a /etc/systemd/system/. Requiere que el usuario SSH tenga permisos sudo sin password para systemctl y mv a /etc/systemd/system/.