diff options
-rw-r--r-- | src/catlfish_sup.erl | 8 | ||||
-rw-r--r-- | src/catlfish_web.erl | 6 | ||||
-rwxr-xr-x | tools/compileconfig.py | 15 |
3 files changed, 14 insertions, 15 deletions
diff --git a/src/catlfish_sup.erl b/src/catlfish_sup.erl index 8a8322d..882a017 100644 --- a/src/catlfish_sup.erl +++ b/src/catlfish_sup.erl @@ -9,7 +9,7 @@ start_link(_Args) -> supervisor:start_link({local, ?MODULE}, ?MODULE, []). -gen_http_config(Config, SSLFlag) -> +gen_http_config(Config, SSLOptions, SSLFlag) -> {ChildName, IpAddress, Port, Module} = Config, {ok, IPv4Address} = inet:parse_ipv4strict_address(IpAddress), @@ -20,7 +20,7 @@ gen_http_config(Config, SSLFlag) -> {ssl_opts, SSLOptions} ], {ChildName, - {catlfish_web, start, [WebConfig, Module]}, + {catlfish_web, start, [WebConfig, Module, ChildName]}, permanent, 5000, worker, dynamic}. @@ -31,10 +31,10 @@ init([]) -> {cacertfile, application:get_env(catlfish, https_cacertfile, none)}], Servers = lists:map(fun (Config) -> - gen_http_config(Config, true) + gen_http_config(Config, SSLOptions, true) end, application:get_env(catlfish, https_servers, [])) ++ lists:map(fun (Config) -> - gen_http_config(Config, false) + gen_http_config(Config, SSLOptions, false) end, application:get_env(catlfish, http_servers, [])), lager:debug("Starting servers ~p", [Servers]), {ok, diff --git a/src/catlfish_web.erl b/src/catlfish_web.erl index 5ee5743..f9fe6d6 100644 --- a/src/catlfish_web.erl +++ b/src/catlfish_web.erl @@ -2,14 +2,14 @@ %%% See LICENSE for licensing information. -module(catlfish_web). --export([start/2, loop/2]). +-export([start/3, loop/2]). -start(Options, Module) -> +start(Options, Module, Name) -> lager:debug("Starting catlfish web server: ~p", [Module]), Loop = fun (Req) -> ?MODULE:loop(Req, Module) end, - mochiweb_http:start([{name, Module}, {loop, Loop} | Options]). + mochiweb_http:start([{name, Name}, {loop, Loop} | Options]). add_auth(Path, {Code, Headers, Data}) -> diff --git a/tools/compileconfig.py b/tools/compileconfig.py index f3e858b..4996994 100755 --- a/tools/compileconfig.py +++ b/tools/compileconfig.py @@ -77,7 +77,7 @@ def get_node_config(nodename, config): sys.exit(1) return (nodetype, nodeconfig) -def gen_http_servers(nodetype, nodeconfig, bind_address, bind_publicaddress, public_https): +def gen_http_servers(nodetype, nodeconfig, bind_address, bind_publicaddress, bind_publichttpaddress): if bind_address: (host, port) = parse_address(bind_address) else: @@ -92,10 +92,10 @@ def gen_http_servers(nodetype, nodeconfig, bind_address, bind_publicaddress, pub http_servers = [] https_servers = [] - if public_https: - https_servers.append((Symbol("external_https_api"), publichost, publicport, Symbol("v1"))) - else: - http_servers.append((Symbol("external_http_api"), publichost, publicport, Symbol("v1"))) + if bind_publichttpaddress: + (publichttphost, publichttpport) = parse_address(bind_publichttpaddress) + http_servers.append((Symbol("external_http_api"), publichttphost, publichttpport, Symbol("v1"))) + https_servers.append((Symbol("external_https_api"), publichost, publicport, Symbol("v1"))) https_servers.append((Symbol("frontend_https_api"), host, port, Symbol("frontend"))) return (http_servers, https_servers) @@ -155,15 +155,14 @@ def gen_config(nodename, config, localconfig): paths = localconfig["paths"] bind_address = localconfig.get("addresses", {}).get(nodename) bind_publicaddress = localconfig.get("publicaddresses", {}).get(nodename) + bind_publichttpaddress = localconfig.get("publichttpaddresses", {}).get(nodename) options = localconfig.get("options", []) configfile = open(paths["configdir"] + nodename + ".config", "w") print >>configfile, "%% catlfish configuration file (-*- erlang -*-)" - public_https = "nopublichttps" not in options - (nodetype, nodeconfig) = get_node_config(nodename, config) - (http_servers, https_servers) = gen_http_servers(nodetype, nodeconfig, bind_address, bind_publicaddress, public_https=public_https) + (http_servers, https_servers) = gen_http_servers(nodetype, nodeconfig, bind_address, bind_publicaddress, bind_publichttpaddress=bind_publichttpaddress) catlfishconfig = [] plopconfig = [] |