Files
Cato ab03ca70c3 fix(deploy): cap the app's V8 heap below its cgroup memory limit (#1784)
The app froze six times on 14-15 Nov with its main thread stuck in
__mem_cgroup_handle_over_high: memory sat at 790-850 MiB against the
unit's 768M memory.high, so the kernel throttled it instead of killing
it, and every stop needed SIGKILL. V8 sizes its heap from the machine's
RAM, not the cgroup, so it never ran a full collection before crossing
the throttle point. Run node with --max-old-space-size=512, self-healed
into the box launch.sh on each deploy like the header-size flag.
2026-11-15 07:33:59 +01:00

23 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# OrangeCat app launcher (SSOT) — vendored from the box (/opt/orangecat/app/launch.sh).
# Sources the runtime .env and starts the Next.js standalone server. The
# --max-http-header-size=65536 raises Node's 16KB header cap so a browser with many
# accumulated sb-* auth cookies doesn't get a hard 431 ("won't open in Brave");
# --max-old-space-size=512 keeps V8's heap under the unit's cgroup memory.high
# (768M) so the kernel never throttles the process into a hang.
# deploy-selfhost.sh also self-heals both flags on the box copy each deploy.
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [ -f "$HERE/.env" ]; then
set -a
source "$HERE/.env"
set +a
fi
# `unset` does NOT bind to localhost — it makes Next fall back to ITS OWN
# default, which is 0.0.0.0 (every interface). Found 2026-08-29: this left
# orangecat reachable on all interfaces, mitigated only by ufw's
# default-deny (not something to rely on as the actual boundary).
export HOSTNAME=127.0.0.1
export NODE_ENV="production"
exec /usr/bin/node --max-old-space-size=512 --max-http-header-size=65536 "$HERE/server.js"