< Back to all hacks

#10 Bypass systemd (gateway run)

Runtime
Problem
openclaw gateway start tries to register as systemd service. No systemd in proot.
Solution
Use gateway run (foreground mode). Set DBUS_SESSION_BUS_ADDRESS=disabled.
Lesson
Most server software has a foreground mode. Use it when you control the process lifecycle yourself.

Context

OpenClaw's gateway start command is designed for traditional Linux servers. It tries to register as a systemd service via D-Bus, create a PID file, and daemonize itself. None of this works in a proot environment — there's no systemd, no D-Bus daemon, no init system at all.

Running gateway start inside proot fails immediately with errors about missing D-Bus socket and systemd registration failures. The gateway never actually starts.

Implementation

Use gateway run instead of gateway start. This runs the gateway in foreground mode, bypassing all process management. Disable D-Bus to prevent socket connection attempts:

# Disable D-Bus (no systemd/session bus available)
export DBUS_SESSION_BUS_ADDRESS=disabled:

# Set XDG_RUNTIME_DIR (some libraries expect this)
export XDG_RUNTIME_DIR=/tmp

# Run gateway in foreground mode
npx openclaw gateway run --port 9000

For the full PocketClaw setup with all environment variables:

# Complete gateway launch command:
export DBUS_SESSION_BUS_ADDRESS=disabled:
export XDG_RUNTIME_DIR=/tmp
export UV_THREADPOOL_SIZE=1
export NODE_OPTIONS='-r /root/hijack.js --expose-gc --no-warnings --max-old-space-size=112 --max-semi-space-size=2'
export OPENCLAW_NO_RESPAWN=1

npx openclaw gateway run --port 9000

The OPENCLAW_NO_RESPAWN=1 variable tells OpenClaw not to spawn child worker processes — on a 1 GB device, a single process is all we can afford.

Verification

# Start the gateway and check it's running:
npx openclaw gateway run --port 9000 &
sleep 10

# Check process is running:
pgrep -f "openclaw.*gateway"
# Expected: PID number

# Test API endpoint:
curl -s http://localhost:9000/api/status
# Expected: JSON response with gateway status

# Check no systemd errors in logs:
grep -i "systemd\|dbus" $PREFIX/tmp/openclaw-gateway.log
# Expected: no error lines

Gotchas

  • gateway run runs in the foreground — it will block your terminal. Use setsid (Hack #33) or & to background it
  • The trailing colon in DBUS_SESSION_BUS_ADDRESS=disabled: is required by the D-Bus spec — without it, some libraries try to parse it as an address
  • OPENCLAW_NO_RESPAWN=1 is critical on the Moto E2. Without it, OpenClaw spawns worker processes that each try to allocate their own V8 heap, instantly OOM-killing the device
  • If using proot, run this inside the proot environment. If using native node22-icu (Hack #12), run directly in Termux

Result

MetricBeforeAfter
gateway startFails (no systemd)N/A
gateway runN/AWorks
D-Bus errorsCrash on startNone
Process managementsystemd (broken)Manual (setsid + watchdog)