summaryrefslogtreecommitdiff
path: root/src/catlfish_sup.erl
diff options
context:
space:
mode:
authorMagnus Ahltorp <map@kth.se>2014-10-24 04:37:18 +0200
committerMagnus Ahltorp <map@kth.se>2014-10-24 05:06:23 +0200
commit9229c14078bda5c0386a43fc89fcc5f3f5471670 (patch)
tree938a590994ef4036c6929acd27654d035fa7a02c /src/catlfish_sup.erl
parent02c3707c03bdcc607b05c0fdbfaeaa7f65774de9 (diff)
Use mochiweb for v1 API
Conflicts: catlfish.config src/v1.erl
Diffstat (limited to 'src/catlfish_sup.erl')
-rw-r--r--src/catlfish_sup.erl30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/catlfish_sup.erl b/src/catlfish_sup.erl
new file mode 100644
index 0000000..e8f2de9
--- /dev/null
+++ b/src/catlfish_sup.erl
@@ -0,0 +1,30 @@
+%%% Copyright (c) 2014, NORDUnet A/S.
+%%% See LICENSE for licensing information.
+
+-module(catlfish_sup).
+-behaviour(supervisor).
+
+-export([start_link/1, init/1]).
+
+start_link(_Args) ->
+ supervisor:start_link({local, ?MODULE}, ?MODULE, []).
+
+init([]) ->
+ SSLOptions = [{certfile, application:get_env(catlfish, https_certfile, none)},
+ {keyfile, application:get_env(catlfish, https_keyfile, none)}],
+ Servers = lists:map(fun (Config) ->
+ {IpAddress, Port, Module} = Config,
+ {ok, IPv4Address} = inet:parse_ipv4strict_address(IpAddress),
+ WebConfig = [{ip, IPv4Address},
+ {port, Port},
+ {ssl, true},
+ {ssl_opts, SSLOptions}
+ ],
+ {catlfish_web,
+ {catlfish_web, start, [WebConfig, Module]},
+ permanent, 5000,
+ worker, dynamic}
+ end, application:get_env(catlfish, https_servers, [])),
+ {ok,
+ {{one_for_one, 3, 10},
+ Servers}}.