diff options
-rw-r--r-- | catlfish.config | 2 | ||||
-rw-r--r-- | src/catlfish_sup.erl | 5 | ||||
-rw-r--r-- | src/catlfish_web.erl | 11 | ||||
-rw-r--r-- | test/config/frontend-1-httpd.conf | 21 | ||||
-rw-r--r-- | test/config/frontend-1.config | 6 | ||||
-rw-r--r-- | test/config/storage-1-httpd.conf | 21 | ||||
-rw-r--r-- | test/config/storage-1.config | 11 |
7 files changed, 19 insertions, 58 deletions
diff --git a/catlfish.config b/catlfish.config index 672f997..91868e5 100644 --- a/catlfish.config +++ b/catlfish.config @@ -10,7 +10,7 @@ {catlfish, [{known_roots_path, "known_roots"}, {https_servers, - [{"127.0.0.1", 8080, v1} + [{external_https_api, "127.0.0.1", 8080, v1} ]}, {https_certfile, "catlfish/webroot/certs/webcert.pem"}, {https_keyfile, "catlfish/webroot/keys/webkey.pem"}, 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. diff --git a/test/config/frontend-1-httpd.conf b/test/config/frontend-1-httpd.conf deleted file mode 100644 index 70f91ee..0000000 --- a/test/config/frontend-1-httpd.conf +++ /dev/null @@ -1,21 +0,0 @@ -%%% Copyright (c) 2014, NORDUnet A/S. -%%% See LICENSE for licensing information. -[ - {port, 8082}, - {bind_address, {127, 0, 0, 1}}, - {server_name, "flimsy"}, - {server_root, "catlfish/webroot"}, - {document_root, "catlfish/webroot/docroot"}, - {modules, [mod_alias, mod_auth, mod_esi, mod_get, mod_head, - mod_log, mod_disk_log]}, - {erl_script_alias, {"/ct", [frontend]}}, - {erl_script_nocache, true}, - {error_log, "log/error"}, - {security_log, "log/security"}, - {transfer_log, "log/transfer"}, - {socket_type, - {essl, % See ssl(3erl) for SSL options. - [{certfile, "catlfish/webroot/certs/webcert.pem"}, - {keyfile, "catlfish/webroot/keys/webkey.pem"}, - {cacertfile, "catlfish/webroot/certs/webcert.pem"}]}} -]. diff --git a/test/config/frontend-1.config b/test/config/frontend-1.config index 4505581..79d887d 100644 --- a/test/config/frontend-1.config +++ b/test/config/frontend-1.config @@ -6,13 +6,11 @@ {error_logger_mf_dir, "log"}, {error_logger_mf_maxbytes, 10485760}, % 10 MB {error_logger_mf_maxfiles, 10}]}, - {inets, - [{services, - [{httpd, [{proplist_file, "frontend-1-httpd.conf"}]}]}]}, {catlfish, [{known_roots_path, "known_roots"}, {https_servers, - [{"127.0.0.1", 8080, v1} + [{external_https_api, "127.0.0.1", 8080, v1}, + {frontend_https_api, "127.0.0.1", 8082, frontend} ]}, {https_certfile, "catlfish/webroot/certs/webcert.pem"}, {https_keyfile, "catlfish/webroot/keys/webkey.pem"}, diff --git a/test/config/storage-1-httpd.conf b/test/config/storage-1-httpd.conf deleted file mode 100644 index 2f271f8..0000000 --- a/test/config/storage-1-httpd.conf +++ /dev/null @@ -1,21 +0,0 @@ -%%% Copyright (c) 2014, NORDUnet A/S. -%%% See LICENSE for licensing information. -[ - {port, 8081}, - {bind_address, {127, 0, 0, 1}}, - {server_name, "flimsy"}, - {server_root, "catlfish/webroot"}, - {document_root, "catlfish/webroot/docroot"}, - {modules, [mod_alias, mod_auth, mod_esi, mod_get, mod_head, - mod_log, mod_disk_log]}, - {erl_script_alias, {"/ct", [storage]}}, - {erl_script_nocache, true}, - {error_log, "log/error_storage"}, - {security_log, "log/security_storage"}, - {transfer_log, "log/transfer_storage"}, - {socket_type, - {essl, % See ssl(3erl) for SSL options. - [{certfile, "catlfish/webroot/certs/webcert.pem"}, - {keyfile, "catlfish/webroot/keys/webkey.pem"}, - {cacertfile, "catlfish/webroot/certs/webcert.pem"}]}} -]. diff --git a/test/config/storage-1.config b/test/config/storage-1.config index 5b67bbf..b176e1f 100644 --- a/test/config/storage-1.config +++ b/test/config/storage-1.config @@ -6,9 +6,14 @@ {error_logger_mf_dir, "log"}, {error_logger_mf_maxbytes, 10485760}, % 10 MB {error_logger_mf_maxfiles, 10}]}, - {inets, - [{services, - [{httpd, [{proplist_file, "storage-1-httpd.conf"}]}]}]}, + {catlfish, + [{https_servers, + [{storage_https_api, "127.0.0.1", 8081, storage} + ]}, + {https_certfile, "catlfish/webroot/certs/webcert.pem"}, + {https_keyfile, "catlfish/webroot/keys/webkey.pem"}, + {https_cacertfile, "catlfish/webroot/certs/webcert.pem"} + ]}, {lager, [{handlers, [{lager_console_backend, info}, |