radio.service.example 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # systemd unit for the daveo-radio node app — /etc/systemd/system/radio.service
  2. # ============================================================================
  3. #
  4. # An alternative to pm2 (ecosystem.config.cjs). Use ONE of the two, not both.
  5. #
  6. # Runs the app as a long-lived service behind Apache (see
  7. # apache-radio.conf.example). Adjust User/Group and WorkingDirectory to match
  8. # where the repo is checked out on the server.
  9. #
  10. # BUILD LOCALLY — this app serves the built bundle in app/, which is gitignored,
  11. # and systemd does NOT build. Code is synced by FTP, so build on your machine
  12. # (`npm run build`) and include app/ in the upload. The server only needs the
  13. # runtime deps:
  14. #
  15. # npm ci --omit=dev # 5 runtime deps only, no build tooling
  16. #
  17. # Then:
  18. # sudo cp deploy/radio.service.example /etc/systemd/system/radio.service
  19. # sudo systemctl daemon-reload
  20. # sudo systemctl enable --now radio
  21. # systemctl status radio
  22. # journalctl -u radio -f # logs (startup + connection events)
  23. #
  24. # Redeploy: `npm run build` locally -> FTP up app/ + changed files ->
  25. # sudo systemctl restart radio (npm ci again only if package.json changed)
  26. [Unit]
  27. Description=daveo-radio (Icecast player + socket.io chat, node)
  28. After=network.target
  29. [Service]
  30. Type=simple
  31. User=www-data
  32. Group=www-data
  33. WorkingDirectory=/var/www/radio
  34. ExecStart=/usr/bin/node app.js
  35. Restart=on-failure
  36. RestartSec=2
  37. # Config. Mirrors .env.example. DAW_ORIGIN is intentionally absent — it is a
  38. # local-dev-only shim for the shared chrome and must NOT be set in production.
  39. Environment=NODE_ENV=production
  40. Environment=PORT=3002
  41. Environment=BASE_PATH=/radio
  42. Environment=TRUST_PROXY=1
  43. Environment=STREAM_URL=https://stream.davidawindham.com/stream
  44. Environment=STREAM_STATUS_URL=https://stream.davidawindham.com/status-json.xsl
  45. Environment=STREAM_MOUNT=/stream
  46. Environment=LASTFM_USER=windhamdavid
  47. # The Last.fm key is the one secret. Keep it out of this world-readable unit:
  48. # put it in a drop-in that root owns, chmod 600 --
  49. # sudo systemctl edit radio
  50. # and add:
  51. # [Service]
  52. # Environment=LASTFM_API_KEY=xxxxxxxx
  53. # Unset => the sidebar lists stay empty; the app still runs.
  54. [Install]
  55. WantedBy=multi-user.target