Skip to content

Day-to-day operations ​

Everyday actions on the servers. First connect over SSH to the right machine.

MachineEnvironment
trinity-devdev
trinity-prodprod

The IP addresses are in infra/ansible/inventory.ini.

See what is running ​

devprod
The applicationsdocker compose -p trinity psdocker service ls
Task history—docker service ps trinity_web
Traefikdocker ps --filter name=trinity-traefiksame

Read the logs ​

devprod
APIdocker logs -f trinity_apidocker service logs -f trinity_api
Webdocker logs -f trinity_webdocker service logs -f trinity_web
Databasedocker compose -p trinity logs -f dbdocker service logs -f trinity_db
Traefik (one line per request)docker logs -f trinity-traefiksame
Runnerjournalctl -u gitlab-runner -fsame

Logs do not survive a redeployment

They live in the containers. A recreated container starts with empty logs. See Limits.

Redeploy ​

The safest way: retry the deploy-dev or deploy-prod job of the latest pipeline in GitLab (↻ button). It redoes exactly the same deployment.

Restart a service ​

sh
# dev
docker compose -p trinity -f infra/docker-compose.dev.yml restart api

# prod: recreates the tasks one by one, with zero downtime
docker service update --force trinity_api

Open the database ​

sh
# dev
docker compose -p trinity exec db psql -U trinity -d trinity

# prod
docker exec -it $(docker ps -qf name=trinity_db) psql -U trinity -d trinity

The production database

Read-only whenever possible. An UPDATE or DELETE without WHERE cannot be undone, and there is no automatic backup.

Back up the database by hand ​

sh
docker exec $(docker ps -qf name=trinity_db) pg_dump -U trinity trinity > trinity-$(date +%F).sql

Then copy the file off the server.

Change a Traefik route ​

  1. Edit the file in infra/traefik/dynamic/dev/ or prod/, in a merge request.
  2. Once merged, re-run the role:
sh
cd infra/ansible
ansible-playbook playbook.yml --tags traefik --limit prod --ask-vault-pass

Traefik reloads the routes without restarting (watch: true).

Update the servers ​

sh
cd infra/ansible
ansible-playbook playbook.yml --ask-vault-pass

System updates (apt upgrade) are not in the playbook: they are done by hand.