Skip to content
AI GatewayAI Gateway Manual

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.

TaskCommand
Service statedocker compose ps -a
Installed versiongrep '^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.
Logsdocker compose logs -f server web. Each container keeps up to five 50 MB log files.
Restartdocker 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 balancerEdit .env, then ./install.sh install. See Change the hostname.
Clean up old versionsAfter the new version has proven stable, delete aig/<old version>/. Move its backups/ elsewhere first if you still need them.
Terminal window
./install.sh stop

This 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:

Terminal window
./install.sh install

docker 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.

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.

  1. 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/callback to the redirect URIs of the IdP app, and keep the old one until the change is done (see IdP app registration).

  2. Back up .env, then change these four keys:

    APP_ENV=prod
    MANAGEMENT_BASE_URL=https://aig.example.com
    MANAGEMENT_FRONTEND_URL=https://aig.example.com
    MCP_OAUTH_CALLBACK_URL=https://aig.example.com/api/mcp/oauth/callback
    • APP_ENV changes only when you move a localhost install (local to prod). An installation that already has a hostname keeps prod.
    • If the load balancer’s HTTPS port is not 443, include it in all three URLs (https://aig.example.com:8443). AIG_PUBLIC_PORT is read only when .env is created.
    • For a former localhost install, point the load balancer’s target group at AIG_HTTP_PORT as described in Load Balancer.
  3. Apply the change:

    Terminal window
    ./install.sh install

    The installer keeps .env, recreates the containers whose settings changed, and waits for /readyz. Check that the IdP redirect URI it prints is the one you added in step 1.

  4. 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.

  5. 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.
  6. 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.

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_repack needs its PostgreSQL extension installed in the database. The bundled postgres:16.15-alpine image 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 FULL on a running system. It locks the table for the whole rewrite, so every request that writes a log waits.

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):

Terminal window
cd aig/current
docker 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:

Terminal window
cd aig/current
docker compose down -v --remove-orphans
cd ../..
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_KEY of the .env that wrote them. See Secrets and .env.
  • Move certs/tls.crt and certs/tls.key, if an operator added them, and the upgrade backups in aig/<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. Run docker compose -p aig down -v from any directory to remove the remaining containers and volumes. To remove only the volumes, run docker 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.