feat(dev): add instance env manager tooling for multi-instance workflows#307
feat(dev): add instance env manager tooling for multi-instance workflows#307betterclever merged 2 commits intomainfrom
Conversation
Unified script (scripts/instance-env.sh) with subcommands for managing
per-instance env files at .instances/instance-N/{backend,worker,frontend}.env.
- init: generates from .env (preferred) or .env.example with instance-specific
port offsets, DB names, Temporal namespaces, and API URLs
- update: patches only instance-scoped vars, preserving user config
- copy: clones env between instances, auto-adjusting instance vars
- show: displays instance config summary
Justfile gets instance-init/instance-env commands and auto-init hook
in dev start so missing instance env files are created before PM2 startup.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
(cherry picked from commit 0bcd087f7ad9f5ac24a27fdfc153cb5705f068db)
Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 51774af6e3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| validate_instance() { | ||
| local instance="$1" | ||
| [[ "$instance" =~ ^[0-9]+$ ]] || fail "Instance must be a number 0-9. Got: $instance" |
There was a problem hiding this comment.
Disallow leading-zero instance IDs
The validation accepts values like 09, but later arithmetic ($((... + $1 * 100))) treats them as octal and emits errors, which leads to malformed env output (for example PORT= and VITE_API_URL=http://localhost:) while init/show still exit successfully. This is reproducible with ./scripts/instance-env.sh init 09 --force, so users can generate broken instance configs unless instance IDs are normalized or restricted to a single digit before arithmetic.
Useful? React with 👍 / 👎.
Summary
scripts/instance-env.shto manage per-instance env files under.instances/instance-N/(init,update,copy,show)justcommands for active instance management (just instance show|use), env initialization (just instance-init), and env tooling passthrough (just instance-env ...)just dev startwithout overwriting existing filesdocs/MULTI-INSTANCE-DEV.md,README.md, andAGENTS.mdwith the new instance/env workflow and command examplesValidation
bash -n scripts/instance-env.sh scripts/active-instance.shjust instance show./scripts/instance-env.sh init 2./scripts/instance-env.sh update 2./scripts/instance-env.sh copy 2 3 --force./scripts/instance-env.sh show 3just instance-init 4just instance-env show 4just instance-env update 4tsc --buildandbun test(642 pass / 118 skip / 0 fail)