-
Notifications
You must be signed in to change notification settings - Fork 30
Production Runbook
Some notes on maintaining the website in production.
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.
- SSH into the Dokku VM, and
dokku enter brickhack-stage web
- From the shell, run
rails assets:clobber
. This will essentially rm -rf public/assets/ - Immediately after, run
rails assets:precompile
. This will regenerate the current assets. - Exit the shell by entering
exit
. Dokku might not kill the temporary shell container otherwise.
- SSH into the Dokku VM
- Run
dokku mysql:export hm > hm-YYYY-MM-DD.sql
, replacing YYYY-MM-DD with the current date - The SQL backup file is now saved onto the VM
- To download it locally, you can copy it over SFTP with FileZilla or on the command line with SCP:
# On your local computer, which will save to your downloads folder
$ scp [email protected]:/home/username/hm-YYYY-MM-DD.sql ~/Downloads/
Every year before the next round of BrickHack applications are accepted, the old users and questionnaires have to be purged.
- SSH into the Dokku VM, and
dokku enter hm web
- From the shell, run
rails console
. This will delete all users and questionnaires. Run the following code:
Questionnaire.delete_all
User.delete_all
School.where("questionnaire_count > 0").update_all(questionnaire_count: 0)
Once this command completes, you'll likely want to re-create an admin account and promote it to an admin.
- Create an account without completing an application
- From the same Dokku shell in Step 2, run
rails console
- Run
User.last.update_attribute(:role, 'admin')
The alternative 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.
Several pieces of content will need to be updated from previous years.
- Visit https://apply.brickhack.io/manage/configs and review all values.
- Review bus lists (https://apply.brickhack.io/manage/bus_lists)
- Review automated messages (https://apply.brickhack.io/manage/messages)