server
server
¶
Async Unix domain socket server for Marianne daemon IPC.
Binds a Unix socket, accepts concurrent client connections, reads
newline-delimited JSON-RPC 2.0 requests, dispatches them through
RequestHandler, and writes responses back. Handles connection
lifecycle and socket cleanup on shutdown.
Classes¶
DaemonServer
¶
DaemonServer(socket_path, handler, *, permissions=432, backlog=100, max_connections=DEFAULT_MAX_CONNECTIONS, max_concurrent_requests=DEFAULT_MAX_CONCURRENT_REQUESTS, max_streams=DEFAULT_MAX_STREAMS, request_timeout=300.0, write_timeout=10.0, read_idle_timeout=DEFAULT_READ_IDLE_TIMEOUT, enforce_peer_uid=True)
Async Unix domain socket server with JSON-RPC 2.0 routing.
Parameters¶
socket_path:
Filesystem path for the Unix domain socket.
handler:
RequestHandler that dispatches JSON-RPC methods.
permissions:
Octal file permissions applied to the socket after creation.
Defaults to 0o660 (owner + group read/write).
max_connections:
Maximum simultaneous connected clients. FD protection — idle
connections are cheap, so the default is high (~500).
max_concurrent_requests:
Maximum requests being processed at once across all connections.
This is the real concurrency control (~50).
read_idle_timeout:
Seconds a connection may sit between complete messages before the
server closes it (dead/stuck client FD hygiene).
enforce_peer_uid:
Refuse connections whose peer UID differs from the daemon's
effective UID. Defense-in-depth over socket file permissions —
the 0o660 mode admits the owning group, and root bypasses file
modes entirely. On platforms where the peer UID cannot be read
(no SO_PEERCRED) the gate fails open, because absence of the
credential is not evidence of a foreign peer. Unix credentials
are user-granular: this stops other users, not other processes
running as the same user.
Source code in src/marianne/daemon/ipc/server.py
Attributes¶
Methods:¶
start
async
¶
Bind the Unix socket and start accepting connections.
Source code in src/marianne/daemon/ipc/server.py
stop
async
¶
Finish owned cleanup before propagating caller cancellation.