Skip to content

feat: inject daemon running info to tera template#419

Merged
jdx merged 2 commits into
jdx:mainfrom
gaojunran:feat-inject-tera
May 4, 2026
Merged

feat: inject daemon running info to tera template#419
jdx merged 2 commits into
jdx:mainfrom
gaojunran:feat-inject-tera

Conversation

@gaojunran

@gaojunran gaojunran commented May 4, 2026

Copy link
Copy Markdown
Contributor

addresses #405.

@greptile-apps

greptile-apps Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds Tera template support to pitchfork.toml config fields (run, env, hooks.*, ready_cmd), letting daemons reference resolved ports and metadata from their dependencies via {{ daemons.redis.port }} syntax. Templates are rendered level-by-level in batch.rs and re-rendered at hook fire time from state file data, with a TemplateRenderer struct that reuses a single Tera instance per daemon. The two P1 issues from the previous review round (already-running daemons missing from resolved_ports_map, and hook render errors fatally blocking startup) are both addressed in this revision.

Confidence Score: 5/5

Safe to merge; only P2 findings remain.

No P0 or P1 issues found. The two previously flagged P1s are correctly resolved. Remaining findings are a per-daemon read_global_slugs() call (avoidable but not a correctness issue) and an inaccurate doc comment about when hook template warnings are emitted.

src/template.rs — minor doc comment inaccuracy and per-invocation disk I/O in the constructor.

Important Files Changed

Filename Overview
src/template.rs New module: Tera template engine integration with TemplateContext, render_template, and render_daemon_templates. Has a per-daemon read_global_slugs() call (disk I/O) inside the constructor, and a doc comment that misrepresents when hook warnings are logged.
src/ipc/batch.rs Level-by-level template rendering integrated correctly; running daemons' ports are now added to resolved_ports_map before continue, fixing the previously flagged issue where already-running levels would leave next-level templates without port context.
src/supervisor/hooks.rs Adds render_hook_template using state file data at fire time. Hook template errors log a warning and return early, matching documented behaviour. fire_output_hook also gains template rendering.
src/pitchfork_toml.rs Extracts slug-lookup logic into find_slug_for_daemon_in_registry; Err(_) => true fallback (name-only match when namespace can't be resolved) is preserved, consistent with the original list.rs behaviour.
docs/guides/configuration-templates.md New documentation page covering template syntax, variables, resolution order, and error handling; content is accurate with respect to the implementation.

Reviews (4): Last reviewed commit: "fix(template): address minor tera render..." | Re-trigger Greptile

Comment thread src/pitchfork_toml.rs
Comment thread src/template.rs Outdated
@gaojunran gaojunran force-pushed the feat-inject-tera branch from 0e4c5da to fb50cc9 Compare May 4, 2026 08:59
@gaojunran gaojunran force-pushed the feat-inject-tera branch from d493ff3 to bd00558 Compare May 4, 2026 10:28
@gaojunran gaojunran marked this pull request as ready for review May 4, 2026 10:34
@jdx jdx merged commit 5b03518 into jdx:main May 4, 2026
5 checks passed
jdx pushed a commit that referenced this pull request May 5, 2026
## 🤖 New release

* `pitchfork-cli`: 2.9.1 -> 2.10.0

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

##
[2.10.0](v2.9.1...v2.10.0)
- 2026-05-05

### Added

- refine startup / tailing logs display
([#420](#420))
- *(proxy)* sync slug hosts
([#418](#418))
- inject daemon running info to tera template
([#419](#419))

### Fixed

- *(boot-start)* use LaunchDaemon on MacOS
([#423](#423))

### Other

- *(build)* use serious profile to eliminate binary size
([#424](#424))
- set dev profile debug to 1
([#415](#415))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants