Skip to main content

Running in production

  • TLS. Put the console behind your reverse proxy or load balancer, as serve, and bind it to an address only the proxy reaches.
  • Several hosts. The console keeps nothing between requests except its cache, so it can run on several hosts with the same console.yaml. A single sign-on under way lives in the process that started it: send a browser back to the same host (sticky sessions), or run one.
  • Slow or down databases. A store that does not answer costs one connect timeout, tried twice per page. PostgreSQL URLs get connect_timeout=5 unless they set their own; the MySQL driver stops after 10 seconds. To cap a query's time on PostgreSQL, add options=-c%20statement_timeout%3D10000 to the URL (not through PgBouncer, which refuses the options parameter).
  • Locks. The console reads without taking a write lock: SQLite readers go on while a job writes. A DuckDB file allows one writing process or several reading ones, not both: while a job holds its DuckDB state file, the console shows that store as unreachable, and a job that starts during a console read can fail to open it. For stores the console watches, prefer SQLite, PostgreSQL or MySQL.
  • Logs. Each request is logged with the caller's id, its status and duration, and so are sign-ins and acknowledgements; tokens and passwords are not logged. The console takes the same logging options as other commands.

systemd​

streamwright systemd install writes the units of serve and worker. For the console, add one unit by hand:

# /etc/systemd/system/streamwright-console.service
[Unit]
Description=StreamWright console
After=network-online.target
Wants=network-online.target

[Service]
User=streamwright
EnvironmentFile=/etc/streamwright/console.env
ExecStart=/opt/streamwright/venv/bin/streamwright console /etc/streamwright/console.yaml --log-format json
Restart=on-failure
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
PrivateTmp=true

[Install]
WantedBy=multi-user.target
sudo install -m 0600 -o streamwright /dev/null /etc/streamwright/console.env # API key digests, STREAMWRIGHT_SECRET_*
sudo systemctl daemon-reload
sudo systemctl enable --now streamwright-console