Skip to content

Production Runbook

Stuart Olivera edited this page Apr 23, 2019 · 7 revisions

Some notes on maintaining the website in production.

Asset cleanup

Rails and Dokku don't clean up old assets (css, js, images, etc) by itself. This means that on every deploy that an asset changes, both the new and old asset are kept on disk. Over time this can build up to a lot of excess, old assets.

Every once in a while, it's good to purge all assets and regenerate only the current ones.

Warning: this is a destructive, uptime-affecting action. Assets will throw a 404 error until the recompilation step is completed.

  1. SSH into the Dokku VM, and dokku enter brickhack-stage web
  2. From the shell, run rails assets:clobber. This will essentially rm -rf public/assets/
  3. Immediately after, run rails assets:precompile. This will regenerate the current assets.
  4. Exit the shell by entering exit. Dokku might not kill the temporary shell container otherwise.

Yearly website cycle

Back up old data

  1. SSH into the Dokku VM
  2. Run dokku mysql:export brickhack-stage > brickhack-stage-YYYY-MM-DD.sql, replacing YYYY-MM-DD with the current date
  3. The SQL backup file is now saved onto the VM
  4. To download it locally, you can copy it over SFTP with FileZilla or on the command line with SCP:
$ scp scp freedom.csh.rit.edu:/users/u22/stuart/classes/cs724-project/caches/deviation_migration.pickle /Users/stuart/dev/classes/cs724-project/caches/deviation_migration.pickle

### Clean out old data

Every year before the next round of BrickHack applications are accepted, the old users and questionnaires have to be purged.

1. SSH into the Dokku VM, and `dokku enter brickhack-stage web`
2. From the shell, run `rails tools:reset_questionnaires`. **This will delete all users and questionnaires.**

One this command completes, you'll likely want to re-create an admin account and promote it to an admin.
1. Create an account without completing an application
2. From the same Dokku shell in Step 2, run `rails console`
2. Run `User.last.update_attribute(:admin, true)`

The alternate to this is just dropping & re-creating the database, but this benefits from keeping old bus lists & bulk emails in the database for reference and keeping school records & duplicate name resolution.

### Update old content & configuration

Several pieces of content will need to be updated from previous years. These may include:

1. `config/hackathon.yml` - dates, names, etc
2. Other HTML in `app/views/` that may be year-specific
3. Bus lists (https://brickhack.io/manage/bus_lists)
4. Automated messages (https://brickhack.io/manage/messages)
5. Static, automated messages in `app/views/mailer/`
Clone this wiki locally