barrel_mcp_listener_sup (barrel_mcp v3.0.0)
View SourceSupervisor for HTTP listeners.
Listeners are started at runtime with caller-supplied config, so they cannot be static children of barrel_mcp_sup. They are added here instead, which gets them the two things a bare spawn never had: a restart when one crashes, and termination when the application stops rather than an orphan holding the port.
restart => transient, so a deliberate stop stays stopped while a crash is restarted. The restart intensity bounds a listener that cannot bind its port, which would otherwise loop.
Running without the application
The transports can also be driven with no barrel_mcp application around them, the same way barrel_mcp_http_engine:ensure_session_manager/0 copes with a missing supervisor. When this supervisor is not running, both functions below fall back to the unsupervised listener and the caller owns its lifecycle.
Summary
Functions
Start a listener under supervision, or standalone when the supervisor is not running.
Stop a listener and forget its child spec, so the same name can be started again.
Functions
-spec start_listener(atom(), map(), barrel_mcp_http_engine:config()) -> {ok, pid()} | {error, term()}.
Start a listener under supervision, or standalone when the supervisor is not running.
-spec stop_listener(atom()) -> ok | {error, not_found}.
Stop a listener and forget its child spec, so the same name can be started again.