summaryrefslogtreecommitdiffhomepage
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/apply-memory-limits.sh45
-rwxr-xr-xbin/build2
-rwxr-xr-xbin/install4
-rwxr-xr-xbin/up8
4 files changed, 53 insertions, 6 deletions
diff --git a/bin/apply-memory-limits.sh b/bin/apply-memory-limits.sh
new file mode 100755
index 0000000..f5c9cf0
--- /dev/null
+++ b/bin/apply-memory-limits.sh
@@ -0,0 +1,45 @@
+#!/usr/bin/env bash
+# apply-memory-limits.sh — apply the MemoryMax/MemoryHigh cgroup limits to the
+# LIVE dispatch.service WITHOUT a full reinstall. Safe to run while the server
+# is up (the limits take effect on the next restart).
+#
+# What it does (all privileged lines use sudo):
+# 1. Copies the updated dispatch.service template to /etc/systemd/system/ (sudo)
+# 2. Reloads systemd so it picks up the new unit file (sudo)
+# 3. Restarts dispatch so the cgroup limits are applied (sudo)
+#
+# Why sudo: /etc/systemd/system/ is root-owned; daemon-reload and restart
+# require root. The script carries its own sudo — run it directly (no sudo prefix).
+#
+# Run: ./bin/apply-memory-limits.sh
+
+set -euo pipefail
+
+HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+ROOT="$(cd "$HERE/.." && pwd)"
+
+SERVICE_SRC="$ROOT/systemd/dispatch.service"
+SERVICE_DST="/etc/systemd/system/dispatch.service"
+
+if [ ! -f "$SERVICE_SRC" ]; then
+ echo "apply-memory-limits: template not found at $SERVICE_SRC" >&2
+ exit 1
+fi
+
+echo "[apply] copying updated dispatch.service → $SERVICE_DST"
+# Patch in the real user (same as bin/install does)
+REAL_USER="${SUDO_USER:-$USER}"
+REAL_GROUP=$(id -gn "$REAL_USER" 2>/dev/null || echo "$REAL_USER")
+sed "s/^# User\/Group are set by bin/install.*/User=$REAL_USER\nGroup=$REAL_GROUP/" "$SERVICE_SRC" | sudo tee "$SERVICE_DST" > /dev/null
+sudo chmod 644 "$SERVICE_DST"
+
+echo "[apply] daemon-reload…"
+sudo systemctl daemon-reload
+
+echo "[apply] restarting dispatch (cgroup limits take effect)…"
+sudo systemctl restart dispatch
+
+echo "[apply] done!"
+echo " Status: systemctl status dispatch"
+echo " Memory: systemctl show dispatch -p MemoryHigh -p MemoryMax"
+echo " Logs: journalctl -u dispatch -f"
diff --git a/bin/build b/bin/build
index c410156..ba80955 100755
--- a/bin/build
+++ b/bin/build
@@ -17,7 +17,7 @@ set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT="$(cd "$HERE/.." && pwd)"
BACKEND="$ROOT"
-FRONTEND="$(cd "$ROOT/.." && pwd)/dispatch-web"
+FRONTEND="$(cd "$ROOT/.." && pwd)/frontend"
BUILD_FRONTEND=1
if [[ "${1:-}" == "--no-frontend" ]]; then
diff --git a/bin/install b/bin/install
index d2ab25f..3e2a62f 100755
--- a/bin/install
+++ b/bin/install
@@ -104,6 +104,8 @@ EnvironmentFile=/etc/dispatch/env
WorkingDirectory=/var/lib/dispatch
Restart=on-failure
RestartSec=5
+MemoryHigh=20G
+MemoryMax=24G
StandardOutput=journal
StandardError=journal
@@ -136,7 +138,7 @@ if grep -q 'sk-\.\.\.' /etc/dispatch/env 2>/dev/null; then
echo " 3. journalctl -u dispatch -f"
else
echo "[install] starting service…"
- sudo systemctl start dispatch
+ sudo systemctl restart dispatch
echo ""
echo "[install] done!"
echo " Status: systemctl status dispatch"
diff --git a/bin/up b/bin/up
index c0a7cbf..a049c8c 100755
--- a/bin/up
+++ b/bin/up
@@ -3,19 +3,19 @@
# Ctrl-C stops BOTH cleanly (including the backend's spawned observability collector).
#
# backend (this repo) bun --watch → HTTP :24203 + surface WS :24205 (FULL restart on change)
-# frontend (../dispatch-web) vite → http://localhost:24204 (HMR, in-place)
+# frontend (../frontend) vite → http://localhost:24204 (HMR, in-place)
#
-# Assumes dispatch-web is a sibling of this repo. Run: bin/up (or: bun run dev:all)
+# Assumes frontend is a sibling of this repo. Run: bin/up (or: bun run dev:all)
set -uo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # .../arch-rewrite/bin
BACKEND="$(cd "$HERE/.." && pwd)" # backend repo root
-FRONTEND="$(cd "$HERE/../.." && pwd)/dispatch-web" # sibling repo
+FRONTEND="$(cd "$HERE/../.." && pwd)/frontend" # sibling repo
if [ ! -d "$FRONTEND" ]; then
echo "up: frontend repo not found at $FRONTEND" >&2
- echo "up: check out 'dispatch-web' beside this repo and retry." >&2
+ echo "up: check out 'frontend' beside this repo and retry." >&2
exit 1
fi