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>
1.5 KiB
1.5 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 | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| systemd_local_status | function | bash | infra | 1.0.0 | impure | systemd_local_status(name: string, log_lines: int = 10) -> json | Devuelve el estado de un servicio systemd local: active state, sub state, PID, enabled, y las N últimas líneas de journalctl. No requiere sudo. |
|
false | error_go_core |
|
JSON {name, active, sub, enabled, pid, logs:[...]}. Errores a stderr, exit 1. | false | bash/functions/infra/systemd_local_status.sh |
Ejemplo
source bash/functions/infra/systemd_local_status.sh
systemd_local_status "sqlite_api" 5
# {"name":"sqlite_api","active":"active","sub":"running","enabled":"enabled","pid":12345,"logs":["...","..."]}
Valores típicos
active:active,inactive,failed,activating,deactivatingsub:running,dead,exited,start-pre, etc.enabled:enabled,disabled,static,masked
Notas
- No requiere sudo (solo lectura).
- Si el unit no existe,
activeseráinactiveysubserádead. - Los logs vienen de
journalctl -u <name> -n N --no-pager -o cat(sin prefijos, solo el mensaje).