nova_sup (nova v0.18.1)

View Source

Nova supervisor.

Owns the Cowboy listeners. The bootstrap application gets one at startup from the cowboy_configuration key, and further applications can be started and stopped at runtime with add_application/2 and remove_application/1.

Each listener owns its own routing table, so an application started on a second port serves only its own routes. Applications added to a listener that is already bound to the same host and port share that listener's table instead.

Summary

Functions

Start a Nova application at runtime.

Every started Nova application, with the listener serving it.

Every Cowboy listener Nova has started. Used by the graceful shutdown in nova_app, which has to drain all of them and not just the first.

Stop a Nova application. Its routes are removed from the listener serving it, and the listener itself is stopped once no applications are left on it.

Starts the supervisor

Functions

add_application(App, Configuration)

-spec add_application(App :: atom(), Configuration :: map()) ->
                         {ok,
                          App :: atom(),
                          Host :: inet:ip_address() | string(),
                          Port :: inet:port_number()} |
                         {error, Reason :: any()}.

Start a Nova application at runtime.

Configuration takes the same shape as the cowboy_configuration environment key. If a listener is already bound to the requested host and port, the application's routes are added to that listener's routing table. Otherwise a new listener is started with a routing table of its own.

get_started_applications()

-spec get_started_applications() ->
                                  [#{app := atom(),
                                     host := inet:ip_address() | string(),
                                     port := inet:port_number(),
                                     listener := ranch:ref()}].

Every started Nova application, with the listener serving it.

listeners()

-spec listeners() -> [ranch:ref()].

Every Cowboy listener Nova has started. Used by the graceful shutdown in nova_app, which has to drain all of them and not just the first.

remove_application(App)

-spec remove_application(App :: atom()) -> ok | {error, not_found}.

Stop a Nova application. Its routes are removed from the listener serving it, and the listener itself is stopped once no applications are left on it.

start_link()

-spec start_link() -> {ok, Pid :: pid()} | ignore | {error, Error :: any()}.

Starts the supervisor