Repository navigation
daemons: use a project reference's name for its port and URL, in the environment and in templates #15944
Replies: 2 comments 1 reply
|
Both parts are in #15956.
If two names fold onto one variable, neither is exported, and a variable a local daemon already sets wins over the reference's. AI-assisted — Tool: Claude Code; model: anthropic/claude-sonnet-5-5; version: 2.1.326. |
|
Thanks, this works well. With mise 2026.11.12 and pitchfork 2.36.0, A daemon's declared [daemons.api]
run = "exec ./bin/api --port $PORT"
port = 4800
proxy = false
url = "http://127.0.0.1:{{ port }}"$ mise env | grep API_
export API_PORT=4800mise passes The mise side of this was part of the use case in jdx/pitchfork#1145. Can you confirm whether or not this is expected? AI-assisted — Tool: pi 1.5.2; model: bifrost/claude-opus-5-5; version: unavailable. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I run two projects side by side with
mise daemons: shop, a web app, and search, an API that shop calls. Each project calls its main daemonapp. shop starts search with aprojectreference, somise daemons start appin shop brings up both:Each project has its own database. Starting and ordering work well. What I can't do is tell shop where search is. shop reads
SEARCH_API_URL, and the value it needs is the URL mise already computed for search'sapp:The sharing docs say this is deliberate: a referenced daemon's exports stay in its own project. That makes sense for search's database, whose
DATABASE_URLwould replace shop's, and for the variable names: search'sAPP_URLwould collide with shop's ownAPP_URL. But it leaves no direct way to wire the two together.What works today
1. Loop over pitchfork's
daemonsmap. In a daemon's env template, a referenced dependency is keyed by its pitchfork ID, not by the reference name, so{{ daemons.search.url }}fails:The key includes a namespace mise generates per checkout, so I match on the daemon's name instead:
It works, but it only finds dependencies, picks the wrong one if two of them share a name, and is hard to read.
2. Ask the other project in
init. search's own environment has the value, so shop's daemon can read it at startup:This gives search's own idea of its URL, but writes the path twice (here and in
project, which isn't templated, so[vars]can't feed both), runs mise again inside each start, and only sees variables named after search's daemon.3. Declare search as a daemon of shop.
dir = "../search"withrun = "exec mise x -- ./bin/search-api --port $PORT"makes it shop's own daemon, soSEARCH_PORTandSEARCH_URLappear as for any local daemon. The cost is copying search's definition into shop, where it drifts.Proposal
Export a referenced daemon's
<NAME>_PORTand<NAME>_URLinto the referencing project, named after the reference, not the referenced daemon.[daemons.search] project = "../search", name = "app"exportsSEARCH_PORTandSEARCH_URL:shop's daemon runs through
mise x, so the value reaches its process with no template.Naming them after the reference is what makes this safe where exporting search's own variables wasn't: shop chose the name
search, so it can't collide with shop'sAPP_*, and the existing rules still apply to it (two names that fold onto one variable export neither, a preset's variables win, a withdrawn hostname gives no URL). Only those two variables cross over. The referenced daemon's own dependencies export nothing here: shop'sDATABASE_URLis still its own database on 5432, not search's on 5433.I tried the exports locally against
main, and they fit the existing loading code with a small change. An import'sexportsare computed under the local key where the reference is resolved, through the same functionbuild()uses for local daemons, and two!importedfilters are dropped so the existing collision passes andenv_entriesinclude it. I'm happy to share the diff if it's useful.The exports also make worktrees easy to pair. A personal config file can repoint the reference without touching shop's committed config or its
appdaemon, and the variables follow it. For example, to pair shop with a search worktree:A file like that is easy to generate per pairing, and shop's
SEARCH_API_URLneeds no change.Pitchfork templates
mise already does most of the work this pairing takes in plain pitchfork. I tried it there, with shop in
~/.worktrees/shop/fix-rankingand search in~/.worktrees/search/fix-ranking:fix-ranking, so starting shop's daemon answeredDaemon fix-ranking/app is already running. mise generates a namespace per checkout.pitchfork.local.toml, which only works when the committed config sets none; otherwise loading fails withnamespace does not match directory-level namespace 'search' declared in …/pitchfork.toml. mise needs no override.[namespaces.<name>]entry per checkout, or the dependency isnot defined. A mise reference is the whole pointer.[daemons.app]inpitchfork.local.tomlreplaces the committed one, and with onlydependsit fails withmissing field run. mise's personal file repoints the reference and leavesappalone.daemons["search-fix-ranking.app"].That last one mise can't avoid either. The exports cover the environment, but not a pitchfork template, such as
run,ready_cmdor a daemon's ownenv:{{ daemons.search.url }}still fails there. I looked into why. mise rewritesdepends = ["search"]to the full pitchfork ID,search-bd9126f3bbca47d/app, because pitchfork only resolves bare names inside one namespace. The namesearchis gone by the time pitchfork builds the template map, and pitchfork has nowhere to keep it.So the second part of the proposal needs pitchfork too: pitchfork accepts a table beside the plain IDs in
depends, and mise writes one for each reference, passing the name shop chose:pitchfork would add the dependency to the template map under
searchas well as its qualified key, so{{ daemons.search.url }}works wherever shop's templates need it. Plain strings would keep their meaning, and mise would keep writing them for everything that isn't a reference. I've opened the pitchfork side here: jdx/pitchfork#1143.AI-assisted — Tool: pi 1.5.2; model: bifrost/claude-opus-5-5; version: unavailable.
All reactions