diff options
| author | Adam Malczewski <[email protected]> | 2026-06-28 14:24:58 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-06-28 14:24:58 +0900 |
| commit | 841e776635d2a93371f302f0617e729626a69fe5 (patch) | |
| tree | c416925f6730a35f2560451ca7c6edaf41e8b1e4 /bin | |
| parent | 71c635f7d8ee01a2b23d5ddfdfc4bff043980052 (diff) | |
| parent | 414080e271ea44df0a7affc154b62e39b51a11a0 (diff) | |
| download | dispatch-841e776635d2a93371f302f0617e729626a69fe5.tar.gz dispatch-841e776635d2a93371f302f0617e729626a69fe5.zip | |
Merge branch 'dev' into feature/workspace-star
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/apply-memory-limits.sh | 45 | ||||
| -rwxr-xr-x | bin/install | 2 |
2 files changed, 47 insertions, 0 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/install b/bin/install index 4899939..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 |
