Skip to content
Baytae Tistear edited this page Jul 7, 2026 · 4 revisions

Server

Parent section: Core Components

The production server hosts the Discord bot, Flask dashboard, database, media storage, update tooling, backups, and maintenance scripts.

For a full first-time production install, start with Server Installation.

Production Path

The standard production path is:

/home/ubuntu/discord-screenshot-bot

The main production files are:

  • bot.py - Discord bot and slash commands.
  • dashboard.py - Flask dashboard and APIs.
  • config.py - environment loading.
  • database_migrations.py - SQLite migrations.
  • database_backend.py - database abstraction and experimental PostgreSQL mode.
  • config.json - non-secret guild/server configuration.
  • sdac.db - production SQLite database.
  • media/ - uploaded media.
  • scripts/ - install, update, backup, restore, migration, and support helpers.
  • systemd/ - service templates.
  • nginx/ - reverse-proxy helpers.

Services

Expected services:

  • sdac-bot.service - runs the Discord bot.
  • sdac-dashboard.service - runs the Flask dashboard when installed as a service.
  • nginx - reverse proxy and HTTPS endpoint when configured.

Useful commands:

sudo systemctl daemon-reload
sudo systemctl restart sdac-bot
sudo systemctl restart sdac-dashboard
sudo systemctl status sdac-bot --no-pager
sudo systemctl status sdac-dashboard --no-pager

Environment Variables

Document variable names only. Do not paste values into the wiki.

Core variables:

  • DISCORD_TOKEN - Discord bot token.
  • DISCORD_CLIENT_ID - Discord OAuth/application client ID.
  • DISCORD_CLIENT_SECRET - Discord OAuth client secret.
  • DISCORD_REDIRECT_URI - OAuth callback URL.
  • SDAC_ADMIN_KEY - dashboard admin URL key when used.
  • SDAC_PUBLIC_BASE_URL - public dashboard base URL when configured.
  • SDAC_MEDIA_PUBLIC_BASE_URL - optional public media mirror base URL.
  • SDAC_DATABASE_URL - experimental PostgreSQL connection string.

Production may use a dedicated env file such as:

/etc/sdac-bot/sdac.env

Local Dashboard

The dashboard normally listens locally on:

127.0.0.1:5000

The public site can be served through Nginx and HTTPS, for example:

https://freethefishies.us.to

Nginx And HTTPS

Typical setup:

cd /home/ubuntu/discord-screenshot-bot
SDAC_DOMAIN=freethefishies.us.to bash scripts/install_nginx_site.sh
sudo certbot --nginx -d freethefishies.us.to --cert-name freethefishies.us.to --key-type rsa
sudo certbot renew --dry-run

Health Checks

Basic checks:

curl http://127.0.0.1:5000/health
curl -I https://freethefishies.us.to/health

Admin health:

/admin/health?key=YOUR_ADMIN_KEY

Logs

Useful log commands:

journalctl -u sdac-bot -n 80 --no-pager
journalctl -u sdac-dashboard -n 80 --no-pager
journalctl -u nginx -n 80 --no-pager

Line Endings

Linux shell scripts must use LF line endings. If a command fails with bash\r, the file has Windows CRLF line endings and needs to be normalized before use.

Docker

Docker and Docker Compose files exist for self-hosting. The Ubuntu/systemd path remains the main production path unless explicitly changed.

PostgreSQL

SQLite remains the default live database. PostgreSQL support is experimental through SDAC_DATABASE_URL. Test migrations and runtime behavior before using PostgreSQL in production.

Clone this wiki locally