Permalink
Browse files

WHISTLE-1217: start the sync server

  • Loading branch information...
1 parent fc99951 commit c74270200859363e7d92e0b2edefc418f692d995 @k-anderson k-anderson committed Aug 15, 2012
@@ -5,7 +5,7 @@
%%% @end
%%% @contributors
%%%-------------------------------------------------------------------
--module(wh_service_invoices).
+-module(wh_service_sync).
-behaviour(gen_server).
@@ -56,7 +56,8 @@ run() ->
%% @end
%%--------------------------------------------------------------------
init([]) ->
- _TRef = erlang:send_after(1000, self(), {try_sync_service}),
+ SyncPeriod = whapps_config:get_integer(?WHS_CONFIG_CAT, <<"sync_period">>, 600000),
+ _TRef = erlang:send_after(SyncPeriod, self(), {try_sync_service}),
{ok, #state{}}.
%%--------------------------------------------------------------------
@@ -101,7 +102,8 @@ handle_cast(_Msg, State) ->
%%--------------------------------------------------------------------
handle_info({try_sync_service}, State) ->
_ = maybe_sync_service(),
- _TRef = erlang:send_after(1000, self(), {try_sync_service}),
+ SyncPeriod = whapps_config:get_integer(?WHS_CONFIG_CAT, <<"sync_period">>, 600000),
+ _TRef = erlang:send_after(SyncPeriod, self(), {try_sync_service}),
{noreply, State};
handle_info(_Info, State) ->
{noreply, State}.
@@ -118,7 +120,7 @@ handle_info(_Info, State) ->
%% @end
%%--------------------------------------------------------------------
terminate(_Reason, _State) ->
- lager:debug("whistle service invoices terminating: ~p", [_Reason]).
+ lager:debug("whistle service sync terminating: ~p", [_Reason]).
%%--------------------------------------------------------------------
%% @private
@@ -15,9 +15,8 @@
-export([init/1]).
%% Helper macro for declaring children of supervisor
--define(CHILD(Name, Type), fun(N, cache) -> {N, {wh_cache, start_link, [N]}, permanent, 5000, worker, [wh_cache]};
- (N, T) -> {N, {N, start_link, []}, permanent, 5000, T, [N]} end(Name, Type)).
--define(CHILDREN, []).
+-define(CHILD(Name, Type), fun(N, T) -> {N, {N, start_link, []}, permanent, 5000, T, [N]} end(Name, Type)).
+-define(CHILDREN, [{wh_service_sync, worker}]).
%% ===================================================================
%% API functions
@@ -41,6 +41,7 @@
,{whistle_couch_sup, supervisor}
,{?WHAPPS_AMQP_POOL, pool}
,{whapps_controller, worker}
+ ,{whistle_services_sup, supervisor}
]).
%% ===================================================================

0 comments on commit c742702

Please sign in to comment.