c7ae46f86c
Nuevas primitivas para gestionar servicios systemd del sistema desde
el registry (antes solo había versiones remotas via SSH para deploy VPS):
bash/functions/infra/
systemd_local_install_unit — escribir unit en /etc/systemd/system + daemon-reload
systemd_local_enable — systemctl enable
systemd_local_start — systemctl start + MainPID
systemd_local_restart — systemctl restart + MainPID
systemd_local_status — ActiveState/SubState/pid/enabled + journal tail (no sudo)
systemd_local_uninstall — stop + disable + rm unit + daemon-reload (idempotente)
bash/functions/pipelines/
install_systemd_service — pipeline que compone las anteriores; args
--name --exec [--workdir --user --env KEY=VAL
--after --restart --type]
Requisito: sudo sin password para systemctl + escritura en /etc/systemd/system/.
En WSL: systemd=true en /etc/wsl.conf.
Registrado sqlite_api como servicio del sistema con este pipeline, queda
vivo al arrancar WSL. Dashboard ya no necesita arrancar la API manualmente.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2.9 KiB
2.9 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | params | output | tested | tests | test_file_path | file_path | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| install_systemd_service | pipeline | bash | pipelines | 1.0.0 | impure | install_systemd_service --name <N> --exec <PATH> [opts] -> json | Pipeline que registra una app como servicio systemd del sistema: genera el unit, lo instala en /etc/systemd/system/, hace daemon-reload, enable, start y devuelve status. Requiere sudo sin password para systemctl y escritura en /etc/systemd/system/. |
|
|
false | error_go_core |
|
JSON consolidado con subkeys install, enable, start y status de cada paso del pipeline. | false | bash/functions/pipelines/install_systemd_service.sh |
Ejemplo
source bash/functions/pipelines/install_systemd_service.sh
install_systemd_service \
--name sqlite_api \
--exec /home/egutierrez/fn_registry/projects/fn_monitoring/apps/sqlite_api/sqlite_api \
--workdir /home/egutierrez/fn_registry/projects/fn_monitoring/apps/sqlite_api \
--env FN_REGISTRY_ROOT=/home/egutierrez/fn_registry \
--description "fn_registry sqlite_api (read-only HTTP API)"
Salida (resumida):
{
"install": {"name":"sqlite_api","path":"/etc/systemd/system/sqlite_api.service","installed":true},
"enable": {"name":"sqlite_api","enabled":true},
"start": {"name":"sqlite_api","started":true,"pid":12345},
"status": {"name":"sqlite_api","active":"active","sub":"running","enabled":"enabled","pid":12345,"logs":["..."]}
}
Requisitos
systemdactivo en la máquina (en WSL:systemd=trueen/etc/wsl.conf).sudosin password parasystemctly escritura en/etc/systemd/system/.
Notas
- Idempotente: si el unit ya existe, se sobrescribe y systemd se recarga.
- Para desinstalar usar
systemd_local_uninstall <name>. - Orden determinista de Environment= (uno por línea, en el orden pasado en CLI).
- El pipeline NO compila el binario — se asume que
--execapunta a un ejecutable ya listo.