Repository navigation
chore(build): re-apply build-reorg follow-ups (compat fallback + deploy docs) #3127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4ce2e18
757d88e
96f3d22
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,17 +54,20 @@ ssh root@192.168.0.15 "cp -a /usr/lib/node_modules/omniroute/app /usr/lib/node_m | |
| wait | ||
| ``` | ||
|
|
||
| ### 3. Rsync `dist/` → remote `app/` on both VPSs | ||
| ### 3. Stop the processes, then rsync `dist/` → remote `app/` on both VPSs | ||
|
|
||
| The VPS image directory is still named `app/`; we ship the **contents** of our local `dist/`: | ||
| The VPS image directory is still named `app/`; we ship the **contents** of our local `dist/`. **Stop both running processes FIRST** so `rsync --delete` never removes chunk files out from under a live server — that race produces the transient `[Shutdown] Cannot find module ./chunks/NNNNN.js` seen mid-deploy: | ||
|
|
||
| // turbo-all | ||
|
|
||
| ```bash | ||
| ssh root@69.164.221.35 "pm2 stop omniroute" & ssh root@192.168.0.15 "pm2 stop omniroute" & wait | ||
| rsync -az --delete /home/diegosouzapw/dev/proxys/OmniRoute/dist/ root@69.164.221.35:/usr/lib/node_modules/omniroute/app/ && rsync -az --delete /home/diegosouzapw/dev/proxys/OmniRoute/dist/ root@192.168.0.15:/usr/lib/node_modules/omniroute/app/ | ||
|
Comment on lines
+64
to
65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In the both-VPS workflow, if either Useful? React with 👍 / 👎. |
||
| ``` | ||
|
|
||
| ### 4. Restart + health check on both VPSs | ||
| ### 4. Start + health check on both VPSs | ||
|
|
||
| `pm2 restart` on a stopped app starts it again with a clean module graph: | ||
|
|
||
| ```bash | ||
| ssh root@69.164.221.35 "pm2 restart omniroute --update-env && pm2 save" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,3 +54,35 @@ test("serve command: --port option has no Commander default", async () => { | |
| // Ensure the option does NOT have a third argument (Commander default) | ||
| assert.match(serveSource, /\.option\("--port <port>",\s*t\("serve\.port"\)\)/); | ||
| }); | ||
|
|
||
| /** | ||
| * Replicate the APP_DIR resolution from bin/cli/commands/serve.mjs to verify the | ||
| * backward-compatibility fallback introduced by the build-output-isolation refactor: | ||
| * the standalone bundle now ships in `dist/`, but an upgrade over a partially-replaced | ||
| * install — or a package built before the rename — must still boot from legacy `app/`. | ||
| */ | ||
| function resolveAppDir(root: string, distServerExists: boolean): string { | ||
| return distServerExists ? `${root}/dist` : `${root}/app`; | ||
| } | ||
|
|
||
| test("serve app dir: resolves to dist/ when dist/server.js exists (current layout)", () => { | ||
| assert.equal(resolveAppDir("/opt/omniroute", true), "/opt/omniroute/dist"); | ||
| }); | ||
|
|
||
| test("serve app dir: falls back to legacy app/ when dist/server.js is absent (upgrade safety)", () => { | ||
| assert.equal(resolveAppDir("/opt/omniroute", false), "/opt/omniroute/app"); | ||
| }); | ||
|
|
||
| test("serve command: APP_DIR keeps the dist/ -> app/ backward-compat fallback", async () => { | ||
| const fs = await import("node:fs"); | ||
| const path = await import("node:path"); | ||
| const serveSource = fs.readFileSync( | ||
| path.resolve(import.meta.dirname, "../../bin/cli/commands/serve.mjs"), | ||
| "utf-8", | ||
| ); | ||
| // Must probe dist/server.js and fall back to app/ — never hard-code dist/ only. | ||
| assert.match( | ||
| serveSource, | ||
| /existsSync\(join\(ROOT, "dist", "server\.js"\)\)\s*\?\s*join\(ROOT, "dist"\)\s*:\s*join\(ROOT, "app"\)/, | ||
| ); | ||
|
Comment on lines
+84
to
+87
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fragile Test AssertionAsserting on the exact source code formatting and syntax structure (such as the specific ternary operator layout, quote types, and spacing) via a strict regular expression is highly fragile. Any minor, non-functional change—such as running an auto-formatter (e.g., Prettier), changing single quotes to double quotes, or refactoring the ternary operator into an RecommendationMake the assertions more robust and less sensitive to exact formatting by decoupling the checks. You can assert that assert.match(serveSource, /existsSync\s*\(\s*join\s*\(\s*ROOT\s*,\s*['"]dist['"]\s*,\s*['"]server\.js['"]\s*\)\s*\)/);
assert.match(serveSource, /join\s*\(\s*ROOT\s*,\s*['"]app['"]\s*\)/); |
||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the single-host deploy flow, a transient SSH/PM2 failure on the stop command does not prevent the next line from running when this block is pasted or executed without
set -e. That meansrsync --deletecan still update the bundle while the old process is live, which is exactly the chunk-deletion race described above; usessh ... "pm2 stop omniroute" && rsync ...or an explicit failure check before syncing. The same pattern appears in the local VPS skill as well.Useful? React with 👍 / 👎.