Production Environment - Monadical-SAS/oddslingers.poker GitHub Wiki

Docker environment

If your environment is docker see Production management commands for docker

Deploying

Just need to deploy? Jump to Common Tasks

Available Server Commands

# oddslingers-server help
Usage:
   -h | --help         See a list of all functions
   function [args]     Run a function (funcs are defined in /opt/oddslingers.poker/bin/oddslingers-server.fish)

Functions:
   start               Start all production services
   stop                Stop all production services
   stop_heartbeats     Kill all the table heartbeat processes running on production
   manage              Run manage.py [cmd] [args] e.g. migrate
   shell               Open the production django shell_plus
   migrate             Run migrations on the production db
   setup               Run the commands which set up the server and install apt dependencies
   update              Pull a fresh copy of the specified [branch] to the server
   offsite_backup      Backup and save files to remote [host]
   backup              Dump a production db backup to 
   load_backup         Load a [oddslingers.sql] backup into the database
   notify              Post a notification to the zulip #logs stream
   clear_caches        Clear CND edge caches, e.g. cloudflare
   chowndirs           Set the correct permissions on the data dirs
   setup_tunnels       Setup stunnels between necessary servers
   deploy              Use deploy function instead of this

Mangement Commands

oddslingers-server manage <command>

[grater]
    active_sessions
    archive_table
    create_admins
    create_demo_data
    daily_report
    integration_test
    safe_shutdown
    send_mass_email
    send_signup_email
    track_analytics_event
    utils

[poker]
    boot_inactive
    bot_heartbeat
    table_heartbeat

...and more, see `oddslingers-server manage help`

Important locations

  • repo: /opt/oddslingers.poker
  • config: /opt/oddslingers.poker/env
  • bin: /opt/oddslingers,poker/bin is added to $PATH
  • etc: files in /etc are symlinked to /opt/oddslingers.poker/etc/
  • data: /data is symlinked to /opt/oddslingers.poker/data
    • logs/ (/var/log/oddslingers.poker is symlinked to data/logs)
    • database/ (/var/lib/postgresql/10/main/ is symlinked to data/database)
    • redis/
    • debug_dumps/
    • geoip/
    • newsletters/
    • support_tickets/

Common Tasks

Starting and stopping services

# always run status first to see which groups are started or stopped & having problems
supervisorctl status

# start or stop whole groups
supervisorctl start blitzka-base:
supervisorctl stop blitzka-bg:
supervisorctl restart blitzka-django:

# start or stop individual services
supervisorctl start blitzka-base:nginx
supervisorctl stop blitzka-bg:botbeat
supervisorctl restart blitzka-django:django-http-worker

For a full list of available services and their configs, see etc/supervisor/<server-name>.conf.

To view the logs for a service and see why it has errors, see /opt/oddslingers.poker/data/logs/<service-name>.log

Backup

oddslingers-server backup

Backups will be saved in /data/backups/grater_<date>.sql.gz.

Deploy

oddslingers-server deploy prod   # always backup first if there are migrations

or

oddslingers-server deploy beta

Deploy Staticfiles Only (no migrations)

oddslingers-server deploystatic prod

Run DB Migrations (e.g. if there are DB integrity errors or columns missing)

oddslingers-server migrate

Clear Cached Pages and Staticfiles (e.g. if it's serving out of date staticfiles)

supervisorctl restart blitzka-base:nginx
oddslingers-server clear_caches

This restarts nginx and pings Cloudflare to empty their content, you can also do this manually on the Cloudflare Dashboard.

Restart Django (e.g. if templates or HTML are out of date or you need to apply a new setting)

supervisorctl restart blitzka-django:

View Logs (to debug issues on production)

cd /data/logs
ls -lah
cat <log_here>.log

View Support Ticket

cd /data/support_tickets/<ticket_short_id>
ls -lah
cat <artifact_here>
⚠️ **GitHub.com Fallback** ⚠️