Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 14eb2a3436
Fetching contributors…

Cannot retrieve contributors at this time

53 lines (39 sloc) 1.738 kB
-module(estatsd_sup).
-behaviour(supervisor).
%% API
-export([start_link/0, start_link/1, start_link/3]).
%% Supervisor callbacks
-export([init/1]).
-define(FLUSH_INTERVAL, appvar(flush_interval, 10000)).
-define(GRAPHITE_HOST, appvar(graphite_host, "127.0.0.1")).
-define(GRAPHITE_PORT, appvar(graphite_port, 2003)).
-define(VM_METRICS, appvar(vm_metrics, true)).
%% ===================================================================
%% API functions
%% ===================================================================
start_link() ->
start_link( ?FLUSH_INTERVAL, ?GRAPHITE_HOST, ?GRAPHITE_PORT, ?VM_METRICS).
start_link(FlushIntervalMs) ->
start_link( FlushIntervalMs, ?GRAPHITE_HOST, ?GRAPHITE_PORT, ?VM_METRICS).
start_link(FlushIntervalMs, GraphiteHost, GraphitePort) ->
start_link( FlushIntervalMs, GraphiteHost, GraphitePort, ?VM_METRICS).
start_link(FlushIntervalMs, GraphiteHost, GraphitePort, VmMetrics) ->
supervisor:start_link({local, ?MODULE},
?MODULE,
[FlushIntervalMs, GraphiteHost, GraphitePort, VmMetrics]).
%% ===================================================================
%% Supervisor callbacks
%% ===================================================================
init([FlushIntervalMs, GraphiteHost, GraphitePort, VmMetrics]) ->
Children = [
{estatsd_server,
{estatsd_server, start_link,
[FlushIntervalMs, GraphiteHost, GraphitePort, VmMetrics]},
permanent, 5000, worker, [estatsd_server]}
],
{ok, { {one_for_one, 10000, 10}, Children} }.
appvar(K, Def) ->
case application:get_env(estatsd, K) of
{ok, Val} -> Val;
undefined -> Def
end.
Jump to Line
Something went wrong with that request. Please try again.