Files
fn_registry/functions/infra/systemd_install.md
T
egutierrez a06946e410 feat: funciones Go de deploy — systemd, VPS setup, deploy remoto
Nuevas funciones infra para deploy sin Docker: generación de units
systemd (pura), instalación/restart/status de servicios remotos via
SSH, setup inicial de VPS (crear dirs, usuario, permisos), y pipelines
de deploy completo (setup_vps_app, deploy_app_remote). Incluye tipo
DeployConfig con la configuración de deploy por app.
2026-04-12 17:29:52 +02:00

42 lines
1.3 KiB
Markdown

---
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/.