arizona_app (arizona v0.4.0)
View SourceOTP application entry point.
Boots arizona_sup, then -- if the server application env is set --
starts a listener named arizona_http through the arizona_server adapter
its required adapter key names, a module of an adapter package the
application depends on (arizona_roadrunner's arizona_roadrunner_server,
arizona_cowboy's arizona_cowboy_server, ...). On shutdown,
drains that listener in prep_stop/1 -- before the supervision tree goes
down -- so it never
serves a request against already-dead infrastructure (pubsub, the MCP
registry, the session store); stop/1 re-runs the same idempotent
cleanup as a backstop. Draining, not just stopping, is what lets clients
come back: each live view gets handle_drain/2 and closes 1001, which
web and native clients reconnect from, where a plain stop closes 1000,
which they take as a deliberate end of session.
Server config
{arizona, [
{server, #{
adapter => arizona_roadrunner_server, %% arizona_server module (required)
scheme => http, %% http | https
transport_opts => [{port, 4040}], %% port shorthand
drain_timeout => 5000, %% ms a stop waits for sessions
proto_opts => #{ %% adapter-specific: roadrunner's
max_clients => 200,
max_content_length => 10485760
},
routes => [
{live, ~"/", my_page, #{layouts => [{my_layout, render}]}},
{ws, ~"/ws", #{}},
{asset, ~"/priv", {priv_dir, my_app, "static"}}
]
}}
]}The server key is optional: if absent, only the supervisor starts
(useful for tests that launch listeners manually).
Summary
Functions
Renders the server env errors this module raises.
Functions
-spec format_error(Reason, Stacktrace) -> ErrorInfo when Reason :: term(), Stacktrace :: [tuple()], ErrorInfo :: #{general := iolist()}.
Renders the server env errors this module raises.
-spec prep_stop(State) -> State when State :: term().
-spec start(StartType, StartArgs) -> StartRet when StartType :: application:start_type(), StartArgs :: term(), StartRet :: {ok, Pid} | {error, ErrReason}, Pid :: pid(), ErrReason :: term().
-spec stop(State) -> ok when State :: term().