http
The http configuration object allows you to customize the network interface and port that the Hive
Router listens on for incoming GraphQL requests.
Options
host
- Type:
string - Default:
"0.0.0.0" - Environment Variable:
HOST
The host property specifies the IP address to which the router’s HTTP server will bind.
"0.0.0.0": Binds to all available network interfaces. This is the standard for services running inside containers."127.0.0.1"or"localhost": Binds only to the local loopback interface, meaning the router will only be accessible from the same machine.
port
- Type:
integer - Default:
4000 - Environment Variable:
PORT
The port property specifies the network port that the router will listen on. Ensure this port is
not already in use by another service on the same host. When running in a container, this is the
port you will need to expose.
workers
- Type:
integer|cpuset|container - Default:
cpuset - Environment Variable:
ROUTER_HTTP_WORKERS
The workers property controls the number of HTTP server worker threads. Set it to:
cpuset— one worker per logical CPU in the process’s CPU affinity mask. On Linux, this follows the cgroup cpuset, but does not account for a CPU quota such as a Kubernetes CPU limit. This is the default.container— likecpuset, but also capped by the container’s cgroup CPU quota, rounded down with a minimum of one worker. For example, a1500mCPU limit results in one worker. If no CPU limit is set, this behaves likecpuset.- A positive integer — use that explicit number of workers.
In containers, use container or an explicit count when the CPU quota is lower than the number of
CPUs in the affinity mask, to avoid oversubscribing worker threads. ROUTER_HTTP_WORKERS accepts
the same values and overrides this setting.
graphql_endpoint
- Type:
string - Default:
/graphql
The graphql_endpoint property specifies the URL path at which the router will expose its GraphQL
API.
You may also use /graphql/{wildcard} if you wish to capture nested paths within the same request,
or /graphql/{tail}* to capture any remaining path segments.
Any named path parameters captured by the pattern (for example, tenant in
graphql_endpoint: /{tenant}/graphql) are exposed to expressions as
.request.path_params, and to plugins through RouterHttpRequest.match_info. See
Dynamic Subgraph Routing
for an example.
shutdown_timeout
- Type:
string - Default:
30s - Environment Variable:
ROUTER_HTTP_SHUTDOWN_TIMEOUT
How long the HTTP server waits for in-flight requests to finish after receiving SIGTERM, before
remaining connections are force-dropped, in duration string format (e.g. 90s, 1m30s). Applies to
both the main server and the dedicated subscription callback server.
Set this above
traffic_shaping.router.request_timeout so the longest
request the router accepts can still finish during a drain. When running under an orchestrator, the
platform’s own grace period (for example Kubernetes’ terminationGracePeriodSeconds) must in turn
exceed shutdown_timeout, otherwise the process is killed before the drain completes.
Example
This example configures the router to listen only on the localhost interface on port 8080, use
container-aware worker sizing, and expose GraphQL on path /my_graphql_router, so it will accept
GraphQL requests on http://127.0.0.1:8080/my_graphql_router.