Skip to content

v2.31.0: Load daemon env from dotenv files and nest groups

Choose a tag to compare

@jdx jdx released this 15 Oct 10:42
· 33 commits to main since this release
Immutable release. Only release title and notes can be modified.
21afa79

Daemons can now load environment variables from dotenv files with env_file, and groups can include other groups so shared daemons are listed only once.

Added

  • env_file loads daemon environment from dotenv files (#1031) by @jdx. You can keep secrets in a git-ignored file such as .env.local instead of a committed pitchfork.toml. Closes #1030.

    [daemons.api]
    run = "npm run server"
    env_file = [".env", ".env.local"]
    env = { NODE_ENV = "development" }
    • Relative paths resolve from the directory of the pitchfork.toml that declares the daemon, and ~ is expanded.
    • Missing files are skipped, so .env.local can be optional. A file that exists but can't be parsed causes an error that names the file.
    • Precedence, from lowest to highest: top-level [env], then earlier files, then later files, then the daemon's own env.
    • Files are parsed the same way mise parses them, including quoting, export prefixes and ${VAR} references. Values go through the same Tera templating as env, so you can use {{ daemons.api.port }}. The values are also available as {{ env.* }} in hook templates.
    • Files are read when the daemon starts, and those values are reused for watch-triggered restarts and automatic retries. Run pitchfork restart to pick up edits to a file. Values from the files are never written back to pitchfork.toml.
  • Groups can include other groups (#1037) by @jdx. Add the new groups key to a group to include other groups:

    [groups.core]
    daemons = ["postgres", "redis"]
    
    [groups.all]
    groups = ["core"]
    daemons = ["api", "worker"]

    pitchfork start --group all starts postgres, redis, api and worker. stop, restart and wait also accept --group all.

    • The daemons from included groups come first, in the order the groups are listed, followed by the group's own daemons. A daemon that appears more than once stays at its first position.
    • Includes can be nested. If several included groups share a group, that is fine.
    • daemons is now optional, so a group can contain only includes.
    • Includes are resolved after configs are merged, so a group can include a group defined in another config file.
    • Including an undefined group is an error with a "did you mean" suggestion. A cycle is also an error and names the chain, for example group include cycle: a -> b -> a. Both errors are reported when the group is used.
    • The web UI stack page also expands includes. If a group's includes can't be resolved, that group is left out and its error is shown on the page. Other groups keep their controls.

Fixed

Full Changelog: v2.30.1...v2.31.0

💚 Sponsor pitchfork

pitchfork is built and maintained by @jdx, an open source developer at entire.io, the title sponsor of his open source work.

If pitchfork has a place in your development workflow, please consider becoming an individual or company sponsor. Your support funds ongoing development and helps keep pitchfork fast, free, and independent.