Repository navigation
v2.37.0: Reusable daemon templates, stepped port bumping, and per-daemon proxy auto-start
LatestYou can now define a set of daemons once and run several numbered or named copies of it. Port bumping can skip ports in fixed steps, and each daemon can override the proxy's global auto-start setting. Configs in a subdirectory of a git worktree now get a separate namespace in each worktree.
Added
-
Daemon templates with numbered or named instances (#1155). A new
[daemon_templates]table defines a set of daemons once, and pitchfork adds a copy of the set for each instance. You no longer have to copy every[daemons.*]block by hand to run one backend per tenant or several worker/API pairs.[daemons.redis] run = "redis-server --port 6379" [daemon_templates.workers] instances = 2 # or a list of names: ["acme", "globex"] [daemon_templates.workers.daemons.api] run = "./api --port $PORT" port = { expect = [3000], bump = 10 } [daemon_templates.workers.daemons.worker] run = "./worker --api http://127.0.0.1:{{ daemons.api.port }} --id {{ instance }}" depends = ["api", "redis"]
This config defines the daemons
workers.0.api,workers.0.worker,workers.1.apiandworkers.1.worker. It also defines one group per instance (workers.0,workers.1) and aworkersgroup that contains every instance. For example,pitchfork start --group workers.1starts a single instance.- Inside a copy,
dependsentries and{{ daemons.<name> }}refer to the daemons of the same instance first, and fall back to regular daemons.asaliases that point at template daemons are redirected to the same instance in the same way. - The new template variables
{{ instance }}and{{ instance_index }}hold the instance name and its position from 0. Outside a template, both are null. - Every copy starts with the same port config. Give listening daemons a
bumprange so each copy can claim the next free port. Proxy hostnames are built from the copy's full name, for exampleworkers-1-api.<project>. - Copies are created after all config files are merged, so
pitchfork.local.tomlcan overrideinstances. A copy or group whose name is already taken is a config error. A template can have at most 1000 instances. - The web UI stack page lists the generated groups. Commands that write config files, such as
pitchfork daemons add, keep[daemon_templates]as written.
See the daemon templates guide for details.
- Inside a copy,
-
Port bump
stepfor daemons limited to evenly spaced ports (#1154). This helps when only certain ports are allowed, for example when an OAuth provider accepts a fixed set of redirect URLs:[daemons.api] run = "node server.js" port = { expect = [4200], bump = 9, step = 10 } # tries 4200, 4210, ... 4290
stepdefaults to 1, so existing configs behave as before, andstep = 0is rejected. When a daemon expects several ports, all of them move by the same step. If the next candidate would be above port 65535, startup fails with the usual "no available port" error instead of wrapping around.stepcan only be set in the config, not on the CLI. It is kept acrosspitchfork restart. -
Per-daemon
proxy_auto_start(#1163), requested by @stephane-klein in #1161. This setting overridessettings.proxy.auto_startfor one daemon, in either direction:[settings.proxy] auto_start = false [daemons.docs] run = "npm run docs" port = 4000 proxy_auto_start = true # starts when its URL is opened
Daemons without the field follow the global setting. When a daemon is auto-started, its dependencies start with it regardless of their own
proxy_auto_start.
Fixed
-
Each git worktree gets its own namespace when
pitchfork.tomlis in a subdirectory (#1168). Before this fix,app/pitchfork.tomlgot the namespaceappin every worktree. As a result,pitchfork start apiin one worktree reported that the daemon from another worktree was already running, andpitchfork stop apistopped the wrong daemon.- In a linked worktree (including worktrees of bare repositories), a namespace derived from a subdirectory now starts with the worktree's directory name. For example,
~/feature-a/app/pitchfork.tomlgets the namespacefeature-a-app. - The main checkout and worktree roots keep their current names.
- An explicit
namespaceand namespaces registered withpitchfork config addstill take precedence. - Derived directory names that are not valid namespaces are now cleaned up instead of failing to load. For example,
review--1234becomesreview-1234. Names with non-ASCII characters still need an explicitnamespace. - After upgrading: daemons that are already running from a subdirectory of a worktree stay registered under their old ID, such as
app/api. Stop them by that qualified ID.
- In a linked worktree (including worktrees of bare repositories), a namespace derived from a subdirectory now starts with the worktree's directory name. For example,
-
Less inotify queue pressure on Linux for file watching (#1174). The
watchfile watcher now filters out access events such asIN_OPENin the kernel, so large recursive watches are less likely to fill the inotify queue. Restart behavior is unchanged.
Full Changelog: v2.36.0...v2.37.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.