Run the gateway
The gateway is the conversation protocol on PostgreSQL. Several replicas share one database, wake each other through LISTEN/NOTIFY (with a polling fallback), and claim agent turns under a lease. This guide runs one gateway against a local database. The deployment example shows the Kubernetes manifests.
Before you start
- PostgreSQL 17 (the version the integration tests use).
- Go 1.27.4.
- The repository checked out.
1. Create the database and migrate it
Migrations run as a database owner, not as the gateway’s roles. Read the owner URL from the environment so it does not appear in the command line:
export ROBOTELOS_DATABASE_URL='postgres://owner@localhost:5432/robotelos?sslmode=disable'
go run ./runtime/cmd/robotelos db migrate up
The migrations create two roles: robotelos_app, which is bound by row level security, and robotelos_worker, which claims queued turns across accounts. Roles are cluster-wide, so the migration creates them only if they are missing and never with a password. Give each role a login, or let a login role SET ROLE to it. See Database migrations.
2. Create a token file
Authentication is a static bearer-token file. It is meant for development and small installations, and the gateway refuses to start without it:
{"tokens": {"a-long-random-secret": {"id": "par_alice", "account": "acct_1", "display": "Alice"}}}
Tokens must be at least 8 characters. Use long random values, and keep the file out of the repository.
3. Set the configuration
export ROBOTELOS_GATEWAY_DATABASE_URL='postgres://robotelos_app:CHANGE_ME@localhost:5432/robotelos?sslmode=disable'
export ROBOTELOS_GATEWAY_WORKER_DATABASE_URL='postgres://robotelos_worker:CHANGE_ME@localhost:5432/robotelos?sslmode=disable'
export ROBOTELOS_GATEWAY_TOKENS_FILE="$HOME/.config/robotelos/tokens.json"
The full list of variables and their defaults is in the gateway configuration reference.
4. Start it
ROBOTELOS_DATAPLANE_ROLES=gateway go run ./runtime/cmd/dataplane
The gateway is a role of the data plane server: one binary, dataplane, runs the roles in ROBOTELOS_DATAPLANE_ROLES (gateway, engine). It serves the conversation protocol with the gateway role. The gateway checks at startup that the application role cannot bypass row level security and that the schema is at least the version it needs. If it cannot start, it logs every configuration problem at once and exits with code 2.
Check that it is up:
curl -s http://127.0.0.1:8787/healthz
curl -s http://127.0.0.1:8787/readyz
/healthz answers while the process is alive. /readyz answers when the gateway can serve requests.
5. Run more replicas
Start more processes with the same configuration. They share the database and wake each other through LISTEN/NOTIFY. Each replica uses ROBOTELOS_GATEWAY_WORKERS concurrent agent turns, so the total throughput is the sum over replicas.
A turn that is not finished within ROBOTELOS_GATEWAY_TURN_LEASE (default 30 seconds) is claimed again by another worker. After ROBOTELOS_GATEWAY_MAX_TURN_ATTEMPTS attempts it ends as failed.
Container and Kubernetes
docker build -f deploy/gateway/Dockerfile -t robotelos-gateway:dev .
kubectl apply -f deploy/gateway/k8s/gateway.yaml
The Kubernetes example is a starting point. Replace the placeholder secrets before you use it anywhere else.
Next steps
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.