Day-to-day operations
Everyday actions on the servers. First connect over SSH to the right machine.
| Machine | Environment |
|---|---|
trinity-dev | dev |
trinity-prod | prod |
The IP addresses are in infra/ansible/inventory.ini.
See what is running
| dev | prod | |
|---|---|---|
| The applications | docker compose -p trinity ps | docker service ls |
| Task history | — | docker service ps trinity_web |
| Traefik | docker ps --filter name=trinity-traefik | same |
Read the logs
| dev | prod | |
|---|---|---|
| API | docker logs -f trinity_api | docker service logs -f trinity_api |
| Web | docker logs -f trinity_web | docker service logs -f trinity_web |
| Database | docker compose -p trinity logs -f db | docker service logs -f trinity_db |
| Traefik (one line per request) | docker logs -f trinity-traefik | same |
| Runner | journalctl -u gitlab-runner -f | same |
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_apiOpen 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 trinityThe 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).sqlThen copy the file off the server.
Change a Traefik route
- Edit the file in
infra/traefik/dynamic/dev/orprod/, in a merge request. - Once merged, re-run the role:
sh
cd infra/ansible
ansible-playbook playbook.yml --tags traefik --limit prod --ask-vault-passTraefik reloads the routes without restarting (watch: true).
Update the servers
sh
cd infra/ansible
ansible-playbook playbook.yml --ask-vault-passSystem updates (apt upgrade) are not in the playbook: they are done by hand.