Operations
Day-to-day commands for a running installation, stopping it, cleaning up old versions, and removing the installation completely.
Run every command in this page from aig/current. The installer refuses to run
from an earlier version directory.
Common tasks
Section titled “Common tasks”| Task | Command |
|---|---|
| Service state | docker compose ps -a |
| Installed version | grep '^VERSION=' .env or docker compose images. Both include the hotfix number. The version field of /healthz shows only the date, and commit is the backend build commit. |
| Logs | docker compose logs -f server web. Each container keeps up to five 50 MB log files. |
| Restart | docker compose restart server web. A changed .env is not applied by a restart; run docker compose up -d instead. |
| Nobody can sign in because the IdP settings are wrong | ./install.sh recover, fix the settings, then ./install.sh recover --done. See Forced recovery after organization creation. |
| Stop | ./install.sh stop (see Stop and start). |
| Change the hostname, or move a localhost install behind a load balancer | Edit .env, then ./install.sh install. See Change the hostname. |
| Clean up old versions | After the new version has proven stable, delete aig/<old version>/. Move its backups/ elsewhere first if you still need them. |
Stop and start
Section titled “Stop and start”./install.sh stopThis removes the containers and the network only. The data volumes, .env, and
every version directory stay, so it is not an uninstall. Start the same
installation again, with the same data and secrets, with:
./install.sh installdocker compose down -v is different: -v deletes the bundled PostgreSQL and
Redis data. Use it only when you mean to remove everything.
It does not touch the data on an external PostgreSQL or Redis.
Change the hostname
Section titled “Change the hostname”The hostname is written into .env only when the file is created. On an
existing installation ./install.sh install --hostname <new hostname> keeps the
old value without a warning, so edit .env instead. The same steps move a
localhost evaluation install (--hostname localhost) behind a load balancer.
The license, data, secrets, and Gateway Keys stay as they are.
-
Prepare the new address. Point the DNS name at the load balancer and attach its certificate (see Load Balancer). Add
https://<new hostname>/api/auth/oidc/callbackto the redirect URIs of the IdP app, and keep the old one until the change is done (see IdP app registration). -
Back up
.env, then change these four keys:APP_ENV=prodMANAGEMENT_BASE_URL=https://aig.example.comMANAGEMENT_FRONTEND_URL=https://aig.example.comMCP_OAUTH_CALLBACK_URL=https://aig.example.com/api/mcp/oauth/callbackAPP_ENVchanges only when you move a localhost install (localtoprod). An installation that already has a hostname keepsprod.- If the load balancer’s HTTPS port is not 443, include it in all three URLs
(
https://aig.example.com:8443).AIG_PUBLIC_PORTis read only when.envis created. - For a former localhost install, point the load balancer’s target group at
AIG_HTTP_PORTas described in Load Balancer.
-
Apply the change:
Terminal window ./install.sh installThe installer keeps
.env, recreates the containers whose settings changed, and waits for/readyz. Check that theIdP redirect URIit prints is the one you added in step 1. -
Sign in at the new address. Browser sessions belong to the old address, so everyone signs in again. Once sign-in works, remove the old redirect URI from the IdP app.
-
For every remote MCP server that uses OAuth, re-register the client with the new Callback URL shown on the server’s edit page. The gateway cannot tell that the provider now rejects the client registered with the old address: the edit page shows no error, but new connections fail on the provider’s page with a redirect URI error.
- Automatically registered client: replace the client with Preview replacement and Confirm replacement. This registers a new client with the new Callback URL, and every user connection to the server becomes Reauthorization required, so users connect again.
- Manually configured client: change the redirect URI of the app in the provider’s console to the new Callback URL. The client in the gateway does not need to be replaced.
-
Tell users the new address. They change it where they configured the gateway (see User Guides), for example in Claude Code, Codex, the Desktop Companion, and other MCP clients. Their Gateway Keys keep working.
Reclaim disk space after log retention
Section titled “Reclaim disk space after log retention”Log retention deletes old Model Logs and MCP Logs
every hour, so llm_logs and mcp_logs stop growing and settle near the size of
the logs kept within the retention period.
PostgreSQL does not give table files back to the operating system after
DELETE. The freed space is reused for new logs once autovacuum has processed
it, so disk use stays flat at about the size of the retained logs. It does not
fall by itself. Right after retention first starts deleting logs, or after you sharply
shorten the period, the files stay large until new logs fill the freed space.
The migration that adds log retention sets autovacuum_vacuum_scale_factor = 0.01
and autovacuum_vacuum_threshold = 10000 on llm_logs and mcp_logs, so
autovacuum starts after about 1% of a table is dead. The migration replaces any
value you set by hand for these two parameters on these two tables. Other tables
and other autovacuum parameters are not changed.
To return space to the operating system, for example after you shortened the
period sharply, run pg_repack on the two tables:
pg_repackneeds its PostgreSQL extension installed in the database. The bundledpostgres:16.15-alpineimage does not include it, so install it yourself or run it where it is available.- It rebuilds a table while the table stays in use, and it needs free disk space of about twice the table plus its indexes while it runs.
- Do not use
VACUUM FULLon a running system. It locks the table for the whole rewrite, so every request that writes a log waits.
Remove the installation
Section titled “Remove the installation”This deletes the containers, the bundled PostgreSQL and Redis volumes, and the
installation root. It cannot be undone. A later installation creates a new
.env, so the field encryption key and the bootstrap token change.
If you want to keep the data, first dump the bundled PostgreSQL and move it out
of the installation root together with .env. Do not continue unless
backup ok is printed (for example, PostgreSQL is stopped or the disk is full):
cd aig/currentdocker compose exec -T postgres pg_dump -U ai_gateway -d ai_gateway -Fc > ../../aig-final.dump && cp -p .env ../../aig-final.env && echo 'backup ok'Then delete everything:
cd aig/currentdocker compose down -v --remove-orphanscd ../..rm -rf aig- A dump alone cannot be restored. Encrypted values (IdP client secret, provider
API keys, and so on) can be read only with the
DB_FIELD_ENCRYPTION_KEYof the.envthat wrote them. See Secrets and .env. - Move
certs/tls.crtandcerts/tls.key, if an operator added them, and the upgrade backups inaig/<version>/backups/before deleting the root. - If the installation root was deleted first and only the volumes remain, a new
installation stops with
an installation (Compose project 'aig') already exists. Rundocker compose -p aig down -vfrom any directory to remove the remaining containers and volumes. To remove only the volumes, rundocker volume rm aig_pgdata aig_redisdata. - Data on an external PostgreSQL or Redis is not deleted. A new installation
generates a new encryption key, so prepare an empty database as described in
External PostgreSQL and Redis. If the
external Redis database number is used only by this installation, clear it
with
FLUSHDB.