# Fablewright under systemd, for a bare Node install with no container. # # 1. Build: pnpm install --frozen-lockfile && pnpm build # 2. Copy: build/, node_modules/, package.json, server.js, scripts/ and drizzle/ to /opt/fablewright # 3. Install: cp deploy/fablewright.service /etc/systemd/system/ # systemctl daemon-reload && systemctl enable --now fablewright # # The unit runs as its own unprivileged user, keeps its state in # /var/lib/fablewright, and restarts on failure. It never runs as root. # # Backups run from a separate timer. See deploy/fablewright-backup.service and # docs/operations.md. [Unit] Description=Fablewright, a self-hosted novel-writing platform Documentation=https://tangled.org/katsuricata.com/Fablewright After=network-online.target Wants=network-online.target [Service] Type=simple User=fablewright Group=fablewright WorkingDirectory=/opt/fablewright # The database and the signing secret live here, and here only. StateDirectory=fablewright StateDirectoryMode=0750 Environment=NODE_ENV=production Environment=PORT=3000 Environment=HOST=127.0.0.1 Environment=DATABASE_URL=file:/var/lib/fablewright/fablewright.db Environment=BODY_SIZE_LIMIT=101M # Set this to the public URL when a proxy terminates TLS in front of the app. # Prefer it over the forwarded headers: it pins the origin the app advertises. # Environment=ORIGIN=https://fable.example.com # Passkeys use ORIGIN. Set this only when ORIGIN is empty for alias domains. # The advertised address is also what a reset mail carries, so mail needs one # of the two. # Environment=INSTANCE_ORIGIN=https://fable.example.com # If the origin cannot be pinned, trust the proxy instead. Use this only when # every request arrives through the proxy and the app is not directly reachable. # Environment=TRUST_PROXY=1 # A long writing session keeps a connection open; do not cut it short. # SHUTDOWN_TIMEOUT gives in-flight saves time to land. Environment=SHUTDOWN_TIMEOUT=30 Environment=KEEP_ALIVE_TIMEOUT=65 ExecStart=/usr/bin/node /opt/fablewright/server.js Restart=on-failure RestartSec=5 # Hardening. The app needs its own state directory and nothing else. NoNewPrivileges=yes PrivateTmp=yes PrivateDevices=yes ProtectSystem=strict ProtectHome=yes ProtectKernelTunables=yes ProtectKernelModules=yes ProtectControlGroups=yes RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX RestrictNamespaces=yes LockPersonality=yes MemoryDenyWriteExecute=yes ReadWritePaths=/var/lib/fablewright [Install] WantedBy=multi-user.target