Welcome to the bouts.app operations manual. This page contains information for bouts.app developers and administrators.
The subsections within this section are meant to be followed in order and describe provisioning a new host using a VPS from DigitalOcean and getting the example.bouts.app
instance set up on it.
example.bouts.app
). Use this name for the hostname too.example
to the IP address.# apt update; apt upgrade
.# apt install postgres postgres-contrib postgresql-12 postgres-client-12
.# apt install golang-go
or # snap install go --classic
.Adapted from crunchydata, Digital Ocean's community tutorial and Web Dev with Go.
scram-sha-256
:
postgresql.conf
file: # vim /etc/postgresql/12/main/postgresql.conf
password_encryption = scram-sha-256
(default is md5
as of time of writing).# systemctl restart postgresql
.psql
as the postgres
user: # sudo -i -u postgres psql
:
postgres
user: \password
. (Using a long, random password. 64 characters is a good length. Save the password somewhere safe.)pg_hba.conf
file: # vim /etc/postgresql/12/main/pg_hba.conf
:
peer
and md5
(in the METHOD
column) with scram-sha-256
.# systemctl restart postgresql
.# psql -U postgres
, then CREATE DATABASE boutsapp_example
.# echo "deb [trusted=yes] https://apt.fury.io/caddy/ /" | sudo tee -a /etc/apt/sources.list.d/caddy-fury.list
# apt update
# apt install caddy
Create a service for the app: # vim /etc/systemd/system/example.bouts.app
, and use the following template:
[Unit]
Description=bouts.app example service
[Service]
WorkingDirectory=/root/bouts.app/example
ExecStart=/root/bouts.app/example/server -prod
Restart=always
RestartSec=30
[Install]
WantedBy=multi-user.target
# cd /root/bouts.app/example
.config.json
file, using the database password and name set in previous steps. Replace pepper
and hmac_key
with long, random strings.{
"domain": "localhost",
"port": 3000,
"env": "prod",
"pepper": "secret-random-string",
"hmac_key": "secret-hmac-key",
"database": {
"host": "localhost",
"port": 5432,
"user": "postgres",
"password": "postgres-password",
"name": "boutsapp_example"
},
"mailgun": {
"from" : "support@bouts.app",
"api_key": "secret-api-key",
"domain": "mg.bouts.app"
}
}
scripts/deploy.sh
and pass the instance name: $ ./scripts/deploy.sh example
.
https://example.bouts.app
.Adding instances to an existing host is simpler than setting one up for the first time. All of the steps will be repeats of steps used to provision and set up a new host. This section will describe setting up an instance called test
.
test.bouts.app
to the server's IP address using an A record.$ psql -U postgres
, then CREATE DATABASE boutsapp_test;
.$ mkdir ~/bouts.app/test
.# vim /etc/systemd/system/test.bouts.app.service
(using the template from before).config.json
to the app directory using the database name (using the template from before), and a new pepper and hmac key. Use a unique port.Caddyfile
.
test.bouts.app
and the reverse_proxy
port to the port you specified in the config.json
.scripts/deploy.sh
with the instance name as an argument: $ ./scripts/deploy.sh test
.In order for a user to edit most resources, they need admin permissions. There can be multiple admins per instance. Admins can edit any exposed element on the instance, so only give permissions to trusted users.
We use permission_lvl = 1
to denote admin permissions, and permission_lvl = 0
for default user permissions.
$ psql -U postgres -d boutsapp_test
.UPDATE users SET permission_lvl = 1 where email = 'newadmin@example.com';
$ ./scripts/deploy.sh test
Methods described in this document can be used to backup and later restore a database, to provide customers a copy of their data, or to transfer the database from one host to another.
This document uses test.bouts.app
as the example instance.
See PostgresSQL Documentation on this topic for more information.
test.bouts.app
, create a db_backup
directory: mkdir /home/postgres/db_backup
.sudo -iu postgres pg_dump boutsapp_test > "/home/postgres/db_backup/boutsapp_test_$(date +%s).sql"
.
boutsapp_test
to the file /home/postgres/db_backup/boutsapp_test_$(date +%s).sql
as user postres
, where $(date +%s)
is the current Unix epoch time.boutsapp_test
database, run ls /home/postgres/db_backup/boustapp_test_*.sql
./home/postgres/db_backup_boutsapp_test_$date.sql
.dropdb -i
command. Verify you have dumped this database before confirming.sudo -iu postgres createdb boutsapp_test
.sudo -iu postgres psql --set ON_ERROR_STOP=on --single-transaction boutsapp_test < "/home/postgres/db_backup_boutsapp_test_$date.sql"
, substituting in the correct file name.rsync
: rsync demo.bouts.app:/home/postgres/db_backup/boutsapp_test_$date.sql path/to/save/location/
.
If you are unable to connect to the server, try pinging it: $ ping demo.bouts.app
. If you receive a response, then the instance is online and something is mis-configured. If you do not receive a response, then the server is offline and needs to be restored.
If the instance is online, connect to it so we can learn more information.
$ systemctl staus caddy.service
.$ systemctl status test.bouts.app
.If either service is inactive, not loaded, or in a failed state, then resolve accordingly. Try restarting the service or turning it on first, and then checking the status to see if the issue is resolved.
If everything is running without error but the app isn't loading, then there may be an issue with the Caddyfile.
Check to see which Caddyfile is being used (reported in systemctl status
output in the caddy run command
), then view that Caddyfile and ensure it is correctly configured.
If that Caddyfile is incorrect, either make the corrections or link the correct Caddyfile to that location (e.g., ln Caddyfile /etc/caddy/Caddyfile
).
commit 99ef0fa3fb96827b961a29bceb60e13f15f86f03 Author: Ethan Madison <ethan@ethanmad.com> Date: 2021-09-19T11:35:18-07:00 Add titles to manual pages Signed-off-by: Ethan Madison <ethan@ethanmad.com>