refactor!: drop services.yaml + yq, hardcode the service registry#48
Merged
Conversation
services.yaml was a build-time registry AND a runtime file parsed by duynhctl with mikefarah yq. The build already clones each service's main branch and builds binaries, so the registry only needs to exist at build time — and a hardcoded table removes the runtime yq dependency entirely. - scripts/lib/common.sh: inline the 9-service registry as bash arrays; the svc_list/svc_field/svc_field_list/svc_build_env accessors keep their names and semantics, so fetch-sources/build-local/render-systemd/stage-all are unchanged. - duynhctl + bash-completion: discover services from /opt/duynhlab/*/ and read PORT from /etc/duynhlab/<svc>.env — no services.yaml, no yq. - spec: drop `Requires: yq` and the %ghost /etc/duynhlab/services.yaml entry. - init-service.sh / stage-all.sh: stop shipping + copying services.yaml. - Makefile + CI: iterate svc_list instead of `yq '.services[].name'`; drop the yq install step. - delete dead packages/rpm/scriptlets/ (nFPM-era, referenced by nothing). - docs (README, AGENTS, 001/003/004/006/007): registry is now the hardcoded block in scripts/lib/common.sh; runtime discovery is filesystem-based. BREAKING CHANGE: /etc/duynhlab/services.yaml is no longer installed and the RPM no longer Requires yq. Adding a service now edits the registry in scripts/lib/common.sh (see docs/006-add-service.md).
Installing then `systemctl enable --now duynhlab-platform.target` now creates every per-service database + roles and runs migrations automatically — no manual `duynhdb bootstrap`/`migrate` loop. - duynhlab-bootstrap.service: Type=oneshot, RemainAfterExit, TimeoutStartSec=3600, pulled in + ordered before duynhlab-infra.target (Requires=/After=), so the backends (After=infra) wait for a ready, migrated schema. - lib/duynhlab-bootstrap: waits for PostgreSQL (pg_isready), then idempotent duynhdb bootstrap + migrate for all 8 backends. - duynhdb bootstrap: local peer auth as the postgres OS user when SUPERUSER_DSN is unset (same-host DB); SUPERUSER_DSN still used for a remote DB. - spec: ship + enable the unit; on upgrade %post restarts it so new migrations apply before backends restart; first-install message rewritten. - ship etc/bootstrap.env.example; operators copy it to /etc/duynhlab/bootstrap.env only for a remote DB. - docs (002/003/007 + README): bootstrap is automatic; manual duynhdb is the fallback / status path.
feat: auto-bootstrap the database via a systemd one-shot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
services.yamlwas both a build-time registry and a runtime file parsed byduynhctlvia mikefarahyq. The build already clones each service'smainand builds binaries, so the registry only needs to exist at build time — and inlining it removes the runtimeyqdependency entirely.scripts/lib/common.sh: hardcoded registry as bash arrays;svc_list/svc_field/svc_field_list/svc_build_envkeep their names + semantics, so fetch/build/render/stage are unchanged.duynhctl+ bash-completion: discover services from/opt/duynhlab/*/and readPORTfrom/etc/duynhlab/<svc>.env— noservices.yaml, noyq.Requires: yqand the%ghost /etc/duynhlab/services.yamlentry;init-service.sh/stage-all.shstop shipping it.svc_list; drop the yq install step.packages/rpm/scriptlets/.BREAKING:
/etc/duynhlab/services.yamlis no longer installed and the RPM no longer Requiresyq. Adding a service now edits the registry inscripts/lib/common.sh(seedocs/006-add-service.md).Verified by dry-run (accessor unit-tests,
render-systemd,duynhctldiscovery fixture,bash -n). Fullmake build/test-installto run in CI.