Skip to content

Comments

feat(dev): add instance env manager tooling for multi-instance workflows#307

Merged
betterclever merged 2 commits intomainfrom
feat/instance-env-manager
Feb 21, 2026
Merged

feat(dev): add instance env manager tooling for multi-instance workflows#307
betterclever merged 2 commits intomainfrom
feat/instance-env-manager

Conversation

@betterclever
Copy link
Contributor

Summary

  • add scripts/instance-env.sh to manage per-instance env files under .instances/instance-N/ (init, update, copy, show)
  • add just commands for active instance management (just instance show|use), env initialization (just instance-init), and env tooling passthrough (just instance-env ...)
  • auto-initialize missing instance env files during just dev start without overwriting existing files
  • update docs/MULTI-INSTANCE-DEV.md, README.md, and AGENTS.md with the new instance/env workflow and command examples

Validation

  • bash -n scripts/instance-env.sh scripts/active-instance.sh
  • just 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 3
  • just instance-init 4
  • just instance-env show 4
  • just instance-env update 4
  • pre-push hook: tsc --build and bun test (642 pass / 118 skip / 0 fail)

betterclever and others added 2 commits February 21, 2026 16:23
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>
@betterclever betterclever merged commit e94f36a into main Feb 21, 2026
3 checks passed
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant