Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Commit

Permalink
Move shard env read to app startup.
Browse files Browse the repository at this point in the history
  • Loading branch information
archaelus committed Oct 31, 2012
1 parent 0b45feb commit bb131e9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
17 changes: 17 additions & 0 deletions src/logplex_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ start(_StartType, _StartArgs) ->
read_availability_zone(),
boot_pagerduty(),
setup_redgrid_vals(),
setup_redis_shards(),
application:start(nsync),
logplex_sup:start_link().

Expand Down Expand Up @@ -120,6 +121,22 @@ setup_redgrid_vals() ->
application:set_env(redgrid, domain, os:getenv("HEROKU_DOMAIN")),
ok.

setup_redis_shards() ->
URLs = case os:getenv("LOGPLEX_SHARD_URLS") of
false ->
erlang:error({fatal_config_error,
missing_logplex_shard_urls});
[] ->
case os:getenv("LOGPLEX_CONFIG_REDIS_URL") of
false -> ["redis://127.0.0.1:6379/"];
Url -> [Url]
end;
UrlString when is_list(UrlString) ->
string:tokens(UrlString, ",")
end,
application:set_env(logplex, logplex_shard_urls,
logplex_shard:redis_sort(URLs)).

logplex_work_queue_args() ->
MaxLength =
case os:getenv("LOGPLEX_QUEUE_LENGTH") of
Expand Down
14 changes: 1 addition & 13 deletions src/logplex_shard.erl
Original file line number Diff line number Diff line change
Expand Up @@ -221,19 +221,7 @@ code_change(_OldVsn, State, _Extra) ->
%%% Internal functions
%%--------------------------------------------------------------------
logs_redis_urls() ->
URLs = case os:getenv("LOGPLEX_SHARD_URLS") of
false ->
erlang:error({fatal_config_error,
missing_logplex_shard_urls});
[] ->
case os:getenv("LOGPLEX_CONFIG_REDIS_URL") of
false -> ["redis://127.0.0.1:6379/"];
Url -> [Url]
end;
UrlString when is_list(UrlString) ->
string:tokens(UrlString, ",")
end,
redis_sort(URLs).
redis_sort(logplex_app:config(logplex_shard_urls)).

populate_info_table(Urls) ->
%% Populate Read pool
Expand Down

0 comments on commit bb131e9

Please sign in to comment.