towerdef/deploy/netwall.service
Claude faf0cfa603 Add co-op server, deploy docs, e2e suite and wire in the music tracks
- server/: Node (ws) static server + authoritative co-op rooms; dual-stack
  listen, proxy-aware client IP and Origin check, keep-alive pings, per-socket
  rate limits, graceful shutdown; 59 node:test tests
- docs/DEPLOY.md + deploy/netwall.service: Debian 13 LXC, systemd, nginx
  Proxy Manager walk-through, path prefix, troubleshooting
- e2e/: Playwright suite (smoke, touch, end flow, two-browser co-op incl.
  reconnect, 14-size layout matrix); npm run e2e
- Music: tracks.json now points at the uploaded theme/battle/boss/win/lose
  files; stingers fade out when a new game starts
- PAUSED indicator, refreshed icon

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tb8pW2KAN4oFkh1aK1BfD8
2026-10-09 19:57:27 +00:00

71 lines
2.7 KiB
Desktop File

# Netwall systemd unit (Debian 13 LXC; see docs/DEPLOY.md).
#
# install -m 0644 deploy/netwall.service /etc/systemd/system/netwall.service
# systemctl daemon-reload && systemctl enable --now netwall
# journalctl -u netwall -f
#
# Expects the app in /opt/netwall (server/, public/, node_modules/) and Debian's /usr/bin/node (Node 20).
[Unit]
Description=Netwall - co-op tower defence (Node server)
Documentation=file:///opt/netwall/docs/DEPLOY.md
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=netwall
Group=netwall
WorkingDirectory=/opt/netwall
ExecStart=/usr/bin/node /opt/netwall/server/index.js
# ---- configuration (see docs/DEPLOY.md, "Configuration") --------------------------------------
Environment=NODE_ENV=production
# Port to listen on. 8080 is unprivileged, so the service needs no capabilities.
Environment=PORT=8080
# "::" = one dual-stack socket for IPv4 + IPv6 (falls back to 0.0.0.0 if the kernel has no IPv6).
Environment=HOST=::
# auto: believe X-Forwarded-For / X-Forwarded-Host only from loopback / private-range peers (your proxy).
Environment=TRUST_PROXY=auto
# Only needed when the proxy rewrites the Host header (symptom: 403 on the WebSocket upgrade).
# Comma separated, e.g. https://game.example.com
#Environment=ALLOWED_ORIGINS=https://game.example.com
#Environment=MAX_CONN_PER_IP=40
#Environment=GRACE_MS=60000
# ---- lifecycle ---------------------------------------------------------------------------------
Restart=on-failure
RestartSec=2
# SIGTERM closes all sockets and exits 0 within about a second; SIGKILL after 10 s as a backstop.
TimeoutStopSec=10
# ---- hardening that works in any container (no mount namespaces needed) -----------------------
NoNewPrivileges=yes
CapabilityBoundingSet=
AmbientCapabilities=
# AF_NETLINK: Node's os.networkInterfaces() (start-up banner) and glibc's resolver use it.
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX AF_NETLINK
RestrictRealtime=yes
RestrictSUIDSGID=yes
LockPersonality=yes
SystemCallArchitectures=native
UMask=0077
# Do NOT add MemoryDenyWriteExecute=yes: V8's JIT needs writable+executable memory and Node would crash.
# ---- optional extra hardening: needs mount namespaces ------------------------------------------
# In an unprivileged Proxmox LXC these fail with "status=226/NAMESPACE" unless the container has the
# "Nesting" feature enabled (Proxmox: container > Options > Features > Nesting; then restart the CT).
# The app writes nothing to disk, so a read-only file system view is fine for it.
#ProtectSystem=strict
#ProtectHome=yes
#PrivateTmp=yes
#PrivateDevices=yes
#ProtectKernelTunables=yes
#ProtectKernelModules=yes
#ProtectKernelLogs=yes
#ProtectControlGroups=yes
#ProtectClock=yes
#ProtectHostname=yes
[Install]
WantedBy=multi-user.target