summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/catlfish_sup.erl5
-rw-r--r--src/catlfish_web.erl11
2 files changed, 8 insertions, 8 deletions
diff --git a/src/catlfish_sup.erl b/src/catlfish_sup.erl
index abdac44..0b6c306 100644
--- a/src/catlfish_sup.erl
+++ b/src/catlfish_sup.erl
@@ -16,7 +16,7 @@ init([]) ->
{cacertfile, application:get_env(catlfish, https_cacertfile, none)}],
Servers =
lists:map(fun (Config) ->
- {IpAddress, Port, Module} = Config,
+ {ChildName, IpAddress, Port, Module} = Config,
{ok, IPv4Address} =
inet:parse_ipv4strict_address(IpAddress),
WebConfig = [{ip, IPv4Address},
@@ -24,11 +24,12 @@ init([]) ->
{ssl, true},
{ssl_opts, SSLOptions}
],
- {catlfish_web,
+ {ChildName,
{catlfish_web, start, [WebConfig, Module]},
permanent, 5000,
worker, dynamic}
end, application:get_env(catlfish, https_servers, [])),
+ lager:debug("Starting servers ~p", [Servers]),
{ok,
{{one_for_one, 3, 10},
Servers}}.
diff --git a/src/catlfish_web.erl b/src/catlfish_web.erl
index cdc1a39..f3231e4 100644
--- a/src/catlfish_web.erl
+++ b/src/catlfish_web.erl
@@ -2,16 +2,14 @@
%%% See LICENSE for licensing information.
-module(catlfish_web).
--export([start/2, stop/0, loop/2]).
+-export([start/2, loop/2]).
start(Options, Module) ->
+ lager:debug("Starting catlfish web server: ~p", [Module]),
Loop = fun (Req) ->
?MODULE:loop(Req, Module)
end,
- mochiweb_http:start([{name, ?MODULE}, {loop, Loop} | Options]).
-
-stop() ->
- mochiweb_http:stop(?MODULE).
+ mochiweb_http:start([{name, Module}, {loop, Loop} | Options]).
loop(Req, Module) ->
"/" ++ Path = Req:get(path),
@@ -42,7 +40,8 @@ loop(Req, Module) ->
end
catch
Type:What ->
- lager:error("Crash in ~p for path ~p: ~p ~n~p~n~p~n", [Module, Path, Type, What, erlang:get_stacktrace()]),
+ [CrashFunction | Stack] = erlang:get_stacktrace(),
+ lager:error("Crash in ~p for path ~p: ~p ~p~n~p~n~p~n", [Module, Path, Type, What, CrashFunction, Stack]),
Req:respond({500, [{"Content-Type", "text/plain"}],
"Internal Server Error\n"})
end.