Skip to content

Self-hosted MCP server + dashboard giving Claude Code, Cursor & Hermes agents shared long-term memory over a git-backed markdown vault. Agent-native, Obsidian-compatible second brain — markdown RAG, no vector DB.

fix(deploy): reap orphaned git helpers — zombies were filling the PID budget

Ronalds Palacis26a7e1a3afda
diff --git a/Dockerfile b/Dockerfile
index 611dac0..16fa9ae 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -3,10 +3,28 @@ FROM oven/bun:1
WORKDIR /app
-# git + certs for the vault clone/sync loop
+# git + certs for the vault clone/sync loop.
+#
+# tini is not optional, and it is the half of the SIGABRT crash loop that lib/git-queue.ts cannot
+# reach. `git pull` forks helpers (remote-https, merge-base) that outlive their parent and get
+# reparented to PID 1. PID 1 here was `bun run start` — a script runner, not an init: it never
+# wait()s, so every pull left ~2 <defunct> git processes behind FOREVER. Measured in production:
+# pids.max=1000, 22 zombie `git` with PPid 1, growing +2 every 30s — the pull loop's cadence, and
+# 1000 PIDs at 4/min is the 4h10m that separated consecutive crashes.
+#
+# Serializing git children throttles how fast the budget fills; it does not empty it. Nothing in
+# the app can: a zombie is only cleared by its parent calling wait(), and by then that parent is
+# PID 1. Once the budget is gone every symptom looks like a network fault — "getaddrinfo() thread
+# failed to start" (libcurl can't start a resolver thread), "cannot fork() for merge-base",
+# "Authentication failed" (the credential helper can't fork) — and finally bun's own posix_spawn
+# returns EAGAIN and the runtime aborts. Memory was never involved: 126 MB against an 8 GB limit.
+#
+# Node-as-PID-1 would not help either: libuv only waitpid()s children it spawned itself, never
+# adopted orphans. An init that reaps is the only fix.
RUN apt-get update \
- && apt-get install -y --no-install-recommends git ca-certificates \
- && rm -rf /var/lib/apt/lists/*
+ && apt-get install -y --no-install-recommends git ca-certificates tini \
+ && rm -rf /var/lib/apt/lists/* \
+ && test -x /usr/bin/tini # fail the BUILD, not the boot, if the path ever moves
COPY package.json bun.lock* ./
RUN bun install --frozen-lockfile
@@ -19,4 +37,8 @@ ENV NODE_ENV=production \
HOSTNAME=0.0.0.0
EXPOSE 3000
+
+# tini runs as PID 1 and reaps adopted orphans. Keep the server as CMD (not baked into the
+# ENTRYPOINT) so a platform-level start command still runs *under* tini rather than replacing it.
+ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["bun", "run", "start"]
diff --git a/railway.toml b/railway.toml
index 95bdc74..e3aeda9 100644
--- a/railway.toml
+++ b/railway.toml
@@ -3,11 +3,15 @@ builder = "dockerfile"
dockerfilePath = "Dockerfile"
[deploy]
-startCommand = "bun run start"
+# No startCommand on purpose. The image is ENTRYPOINT ["/usr/bin/tini","--"] + CMD ["bun","run","start"],
+# and tini as PID 1 is what reaps the orphaned git helpers (see Dockerfile). A platform start command
+# is the one thing that can quietly displace that, so the image owns how the server is launched.
healthcheckPath = "/api/health"
healthcheckTimeout = 100
restartPolicyType = "on_failure"
-restartPolicyMaxRetries = 5
+# 5 was too few: once the PID budget filled, every restart re-crashed within the same minute, the
+# budget was exhausted, and Railway gave up — turning a self-healing crash into hours of hard downtime.
+restartPolicyMaxRetries = 10
# Deploy this repo (the app). Mount a volume at /data and set ENGRAM_DATA_DIR=/data;
# app state + vault clones live there. Vault repos are connected in the dashboard