Skip to content

Move gateway initialization to background #3761

@r4victor

Description

@r4victor

init_gateways() is called synchronously during server startup, blocking the server from accepting requests until all gateways are connected, updated, and configured. With many gateways or slow/unreachable ones, this delays startup by tens of seconds to minutes. This is inconvenient for dev servers and deployments with many gateways.

The three phases inside init_gateways() (connect, update, configure) are parallelized across gateways but run
sequentially phase-by-phase. None of them need to complete before the server can start serving — gateway
connections are established on-demand via get_or_add_gateway_connection() when actually needed.

A subtle point is gateway update/config but even now a failed gateway update is simply logged with a warning, so a new server version should work with older gateways, at least to handle update failures.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions