Files
OmniRoute/scripts/dev/run-standalone.mjs
Diego Rodrigues de Sa e Souza 191dce8d53 Release v3.8.53
Release v3.8.53 — 1,189 documented changes from 1,162 cycle commits and 208 contributor rows; full changelog in CHANGELOG.md → [3.8.53].

Merged by explicit owner decision at STOP #1 on head 6cc69650, without --admin (main has no required checks). Gate / CI passed on this head: 8 unit shards, Coverage and Quality Ratchet. Security: 0 npm, 0 CodeQL high, 0 Dependabot high.

Red at merge, accepted by the owner:
- Gate / Quality and Fast Quality Gates: complexity-ratchets and dead-code compare the whole cycle against main (11 dead exports; total complexity fell from 1,921 to 1,873). Cleanup follows in v3.8.54.
- dast-smoke: advisory.
- Release-Green: FAIL on `unit-6 no result` (cancelled at the 30-minute limit, cause not identified). Pack, boot and the other 64 commands passed on 7e640dee; there is no complete run on this head.

SonarQube is off (SONARQUBE_ENABLED=false). ⚠️ base-red inherited: #18791, #17267.
2026-11-06 04:21:00 -03:00

46 lines
1.7 KiB
JavaScript

#!/usr/bin/env node
import { existsSync } from "node:fs";
import { totalmem } from "node:os";
import {
resolveRuntimePorts,
withRuntimePortEnv,
resolveMaxOldSpaceMb,
calibrateHeapFallbackMb,
warnConflictingHeapLimits,
buildStandaloneNodeOptions,
spawnWithForwardedSignals,
startSelfPinger,
} from "../build/runtime-env.mjs";
import { bootstrapEnv } from "../build/bootstrap-env.mjs";
const env = bootstrapEnv();
const runtimePorts = resolveRuntimePorts(env);
const childEnv = withRuntimePortEnv(env, runtimePorts);
// #2939 / #10353: OMNIROUTE_MEMORY_MB is the Docker/standalone heap knob.
// When it is set, we append --max-old-space-size last (V8 last-flag wins).
// When it is unset and NODE_OPTIONS already pins the heap, keep NODE_OPTIONS
// (#5238). Warn when both are set and the numbers disagree.
const maxOldSpaceMb = resolveMaxOldSpaceMb(
childEnv.OMNIROUTE_MEMORY_MB,
calibrateHeapFallbackMb(totalmem())
);
warnConflictingHeapLimits(childEnv, maxOldSpaceMb);
childEnv.NODE_OPTIONS = buildStandaloneNodeOptions(childEnv, maxOldSpaceMb);
// Prefer the WS-aware wrapper (server-ws.mjs) over the bare Next standalone
// server.js: it installs the trusted peer-IP stamp (scripts/dev/peer-stamp.mjs)
// that the authz middleware needs to allow loopback/LAN access to LOCAL_ONLY
// routes. Falling back to server.js fails CLOSED (every LOCAL_ONLY request 403s)
// rather than trusting the spoofable Host header.
const entry = existsSync("server-ws.mjs") ? "server-ws.mjs" : "server.js";
spawnWithForwardedSignals(process.execPath, [entry], {
stdio: "inherit",
env: childEnv,
});
// Render free-tier keep-alive; inert unless a public URL is configured. See startSelfPinger.
startSelfPinger(childEnv);