add: use SO_REUSEPORT on platform supporting it
This commit is contained in:
committed by
Steve Chavez
parent
de19b04fe4
commit
c297d051dc
@@ -5,6 +5,8 @@ Admin Server
|
||||
|
||||
PostgREST provides an admin server that can be enabled by setting :ref:`admin-server-port` or `:ref:`admin-server-unix-socket`.
|
||||
|
||||
Multiple PostgREST instances can share the same public API host and port when :ref:`server-reuseport` is enabled. Admin ports are not shared: give each instance a different :ref:`admin-server-port`, otherwise the new instance will fail to start.
|
||||
|
||||
.. _health_check:
|
||||
|
||||
Health Check
|
||||
|
||||
@@ -943,6 +943,50 @@ server-port
|
||||
|
||||
The TCP port to bind the web server. Use ``0`` to automatically assign a port.
|
||||
|
||||
.. _server-reuseport:
|
||||
|
||||
server-reuseport
|
||||
----------------
|
||||
|
||||
=============== =================================
|
||||
**Type** Bool
|
||||
**Default** false
|
||||
**Reloadable** N
|
||||
**Environment** PGRST_SERVER_REUSEPORT
|
||||
**In-Database** `n/a`
|
||||
=============== =================================
|
||||
|
||||
Enables ``SO_REUSEPORT`` on the TCP server socket. This allows multiple
|
||||
PostgREST processes to bind to the same :ref:`server-host` and
|
||||
:ref:`server-port` when the operating system supports it.
|
||||
|
||||
For example, two PostgREST processes can use the same configuration:
|
||||
|
||||
.. code:: ini
|
||||
|
||||
server-host = "127.0.0.1"
|
||||
server-port = 3000
|
||||
server-reuseport = true
|
||||
|
||||
New connections are then distributed by the operating system between the
|
||||
running PostgREST processes. This can be used to start a replacement process
|
||||
before stopping the old one, or to run several PostgREST processes behind one
|
||||
port.
|
||||
|
||||
If ``server-reuseport`` is disabled, starting another PostgREST process on
|
||||
the same host and port will fail with the usual address-in-use error.
|
||||
|
||||
Enabling this setting on an operating system that does not support
|
||||
``SO_REUSEPORT`` is a configuration error. PostgREST will fail to start
|
||||
instead of falling back to a normal TCP socket.
|
||||
|
||||
When running multiple PostgREST instances on the same :ref:`server-port`, use
|
||||
a different ``admin-server-port`` for each instance. Admin ports are not shared
|
||||
between instances, so readiness checks always target one specific PostgREST
|
||||
instance.
|
||||
|
||||
This setting does not apply when :ref:`server-unix-socket` is used.
|
||||
|
||||
.. _server-trace-header:
|
||||
|
||||
server-trace-header
|
||||
|
||||
Reference in New Issue
Block a user