From mprocs to devlanes
A small stack migrated from mprocs to devlanes, with the mprocs setup in before/ and the devlanes one in devlanes.yaml. The stack is an npm workspace of TypeScript apps on Hono: an api that keeps text messages in a JSON file, a web page that lists them, a worker without a port that sends queued messages through an sms-stub, and db:migrate and db:seed scripts in the api.
Requirements
Section titled “Requirements”- devlanes, with
devlanes setuprun once - Node 22 or later
- No mprocs or Caddy: the files in
before/are for reading, and this example never runs them
Run it
Section titled “Run it”cd workflows-mprocs-migrationdevlanes startdevlanes start --no-ui prints the start as text:
example-mprocs-migration@0 (main): 3/3 readyready api http://127.0.0.1:20410 https://api.example-mprocs-migration.localhostready web http://127.0.0.1:20411 https://example-mprocs-migration.localhostready worker http://127.0.0.1:20412Open https://example-mprocs-migration.localhost. The page lists three messages marked queued and shows the hostnames that replaced the Caddy ones.
During a start
Section titled “During a start”The first start of a lane runs the
installtask (npm installat the example root,when: lane.create).migrateruns on every start (when: lane.start) and creates the data file in the lane’s data folder,DATA_FILE: ${{ lane.data_path }}/acme.json.The
defaultprofile starts the services taggedessential:apion https://api.example-mprocs-migration.localhost, ready once/healthzanswers (it answers 503 until the data file exists),webon https://example-mprocs-migration.localhost, andworker, ready once it printsworker readyafter its first answer from the api.seedruns once per lane after the services are ready (when: lane.create,after: services) and queues three messages through the api.The worker tries to send them to the stub on
127.0.0.1:4010. The stub is not in the default profile, so they stay queued, anddevlanes logs workersays so:worker#7 sms-stub not reachable at http://127.0.0.1:4010: ECONNREFUSED; 3 queued
Before and after
Section titled “Before and after”The apps read the same variables in both setups, with the old fixed ports as their defaults.
mprocs setup (before/) | devlanes.yaml |
|---|---|
procs., web, worker, sms-stub running npm run dev --workspace apps/<app> | services with run_script: { file: apps/<app>/package.json, name: dev } |
npm install by hand after every checkout | install task with when: lane.create |
API_PORT exported by slot.sh as 4000 + 100 * slot | API_PORT: ${{ self.port }}, for an app that reads its own variable instead of PORT |
PORT=${WEB_PORT:-3000} in web’s shell | nothing: devlanes sets PORT on every service |
PORT=4010 in the stub’s shell | env: { PORT: 4010 }, which only one lane at a time can run |
API_URL, API_PUBLIC_URL, SMS_PUBLIC_URL exported by slot.sh | ${{ services.api.url }}, ${{ services.api.public_url }}, ${{ services.sms_stub.public_url }} |
Caddyfile blocks, one set per slot, and Caddy in docker-compose.yml | hosts on each service, served over HTTPS by the devlanes proxy |
docker-up and docker-down panes | dropped, since they only ran Caddy. A stack with a database moves its Compose file to infra.compose and lists caddy in infra.exclude |
scripts/slot. and its list of worktrees | lanes: every worktree gets its own port block and example-mprocs-migration<N>.localhost |
NODE_OPTIONS: --use-system-ca for Caddy’s local CA | deleted: devlanes sets NODE_EXTRA_CA_CERTS on Node services, and web calls the api over http://127.0.0.1 |
. in the worktree | DATA_FILE: ${{ lane.data_path }}/acme.json |
mprocs., a copy with autostart: false | profiles.default: [+essential] |
| a third copy for backend work, never written | profiles.backend: [+api, +worker, +stub] |
migrate pane, autostart: false | task with when: lane.start |
seed pane, autostart: false | task with when: lane.create and after: services; devlanes run seed for more |
btop pane | devlanes debug top |
Not carried over
Section titled “Not carried over”autorestart: trueonapiandworker. devlanes never restarts a process: a service that exits shows as failed with its log. Every app runs undertsx watch, which restarts it when its code changes.deps: [api]onworker. devlanes starts services together and has no dependencies between them. The worker retries until the api answers and printsworker readyonly then, so itsready.logcheck covers the order. Containers and tasks do run first (infra, thenlane.createandlane.starttasks, then services, thenafter: servicestasks).
Try next
Section titled “Try next”On Windows, add --ssl-revoke-best-effort to the curl commands.
Start the stub with
devlanes start sms-stub. The worker sends the queued messages, and the page shows them assent. With--no-ui:example-mprocs-migration@0 (main): 1/1 readyready sms-stub http://127.0.0.1:4010 https://sms.example-mprocs-migration.localhostdevlanes run seedqueues three more messages, and they go out within two seconds.Start a second lane:
git worktree add ../examples-checkout -b feat/checkout, thencd ../examples-checkout/workflows-mprocs-migration && devlanes start.Without a worktree,
devlanes lane new --name example-mprocs-migration-review --startgives a second lane in the same folder. https://example-mprocs-migration1.localhost showsThis is lane 1 of example-mprocs-migration.with its own api, data file and messages, and there is no slot list or Caddy block to edit.Lane 1’s
SMS_URLishttp://127.0.0.1:4010too, so with lane 0’s stub running, lane 1’s worker sends its seeded messages there.curl -fsS https://sms.example-mprocs-migration.localhost/messageslists them with"from_lane":1.Start the stub in lane 1 with
devlanes start sms-stubin the worktree, ordevlanes start example-mprocs-migration-review:sms-stub --no-uifor thelane newlane. It fails while lane 0 holds the port:example-mprocs-migration@1 (main): not ready, 1 failedfailed sms-stubport 4010 is taken by example-mprocs-migration@0:sms-stubmore: devlanes logs example-mprocs-migration@1:sms-stub --tail 200Switch profiles:
devlanes stop, thendevlanes start --profile backendstartsapi,workerandsms-stubwithoutweb, and the page answers with the proxy’sService not runningpage (503).devlanes start --profile default --profile backendstarts all four, which is whatmprocs.yamlstarted.Run
devlanes debug topfor CPU and memory per lane and service, the job thebtoppane did.Remove the lanes with
devlanes lane clean example-mprocs-migration-review --yesanddevlanes lane clean 0 --yes. Each lane’s data file goes with its data folder.
devlanes.yaml: the services, tasks and profiles, with a comment naming the mprocs, Caddy orslot.shpiece each key replaces.before/:mprocs.yaml,mprocs.essentials.yaml,Caddyfile,docker-compose.ymlandscripts/slot.sh, for reference only.apps/api/: messages inDATA_FILE, listening onAPI_PORT(default 4000), withsrc/scripts/migrate.tsandsrc/scripts/seed.ts.apps/web/: the page, onPORT(default 3000).apps/worker/: sends queued messages toSMS_URL(defaulthttp://127.0.0.1:4010).apps/sms-stub/: the fake SMS provider onPORT(default 4010), with its inbox at/messages.