# StackMemory Portal — systemd unit # # Runs the browser terminal portal 24/7. The Claude Code agent itself lives in # a detached tmux session, so it survives portal restarts and browser closes. # # Install: # sudo cp scripts/portal/stackmemory-portal.service /etc/systemd/system/ # sudo systemctl daemon-reload # sudo systemctl enable --now stackmemory-portal # journalctl -u stackmemory-portal -f # logs (incl. the access URL/token) # # EDIT BEFORE USE: set User=, WorkingDirectory=, and HOME to match your box. # The defaults below assume the common Hetzner "run as root" layout. [Unit] Description=StackMemory Portal (browser terminal for Claude Code) After=network-online.target tailscaled.service Wants=network-online.target [Service] Type=simple User=root WorkingDirectory=/root/work # HOME must be set so the portal finds ~/.stackmemory and Claude's credentials. Environment=HOME=/root Environment=NODE_ENV=production # Bind to 0.0.0.0 so the Tailscale (100.x) address is reachable; Tailscale # itself restricts who can connect, and the portal also requires its token. ExecStart=/usr/bin/env stackmemory portal start --port 7799 --session claude --cwd /root/work Restart=always RestartSec=3 [Install] WantedBy=multi-user.target