-
Notifications
You must be signed in to change notification settings - Fork 6
/
blizanci_app.erl
41 lines (29 loc) · 1.14 KB
/
blizanci_app.erl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
%% blizanci, a Gemini protocol server, by Martin Keegan
%%
%% To the extent (if any) permissible by law, Copyright (C) 2020 Martin Keegan
%%
%% This programme is free software; you may redistribute and/or modify it under
%% the terms of the Apache Software Licence v2.0.
%% @hidden
-module(blizanci_app).
-behaviour(application).
-export([start/2, stop/1, prep_stop/1]).
-define(LISTENER, blizanci_service_ssl).
listen() ->
ok = application:ensure_started(mime_lookup),
ok = application:ensure_started(ranch),
Servlets = blizanci_config:active_servlets(),
[ ok = Servlet:start() || Servlet <- Servlets ],
SSL_Opts = blizanci_config:ssl_opts(),
Proto_Opts = blizanci_config:proto_opts(),
{ok, Listener} = ranch:start_listener(?LISTENER,
ranch_ssl, SSL_Opts,
blizanci_gemini, Proto_Opts),
{ok, Listener}.
start(_StartType, _StartArgs) ->
{ok, _Listener} = listen(), % the _Listener is bound to the ranch pid
{ok, _Pid} = blizanci_sup:start_link().
prep_stop(_State) ->
ok = ranch:stop_listener(?LISTENER).
stop(_State) ->
ok.