Skip to content

Commit

Permalink
support a list of nodes to connect to on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
k-anderson committed May 26, 2011
1 parent 1ad220d commit f549370
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions ecallmgr/priv/settings.config
@@ -0,0 +1 @@
{remote_audio_script, "/usr/local/bin/fetch_remote_audio.sh"}.
1 change: 1 addition & 0 deletions ecallmgr/priv/startup.config
@@ -0,0 +1 @@
{nodes, ['freeswitch@dev.andersonkarl.net']}.
5 changes: 5 additions & 0 deletions ecallmgr/src/ecallmgr.hrl
Expand Up @@ -26,3 +26,8 @@
-define(APP_VERSION, <<"0.7.2">>).

-define(SIP_INTERFACE, "sofia/sipinterface_1/").

-define(STARTUP_FILE, [code:lib_dir(ecallmgr, priv), "/startup.config"]).
-define(SETTINGS_FILE, [code:lib_dir(ecallmgr, priv), "/settings.config"]).


12 changes: 11 additions & 1 deletion ecallmgr/src/ecallmgr_fs_handler.erl
@@ -1,3 +1,4 @@

%%%-----------------------------------------------------------------------------
%%% @author James Aimonetti <james@2600hz.com>
%%% @copyright (C) 2010, James Aimonetti
Expand Down Expand Up @@ -178,7 +179,7 @@ request_node(Type) ->
%%--------------------------------------------------------------------
init([]) ->
process_flag(trap_exit, true),
{ok, #state{}}.
{ok, #state{}, 0}.

%%--------------------------------------------------------------------
%% @private
Expand Down Expand Up @@ -295,6 +296,15 @@ handle_info({nodedown, Node}, #state{fs_nodes=Nodes}=State) ->
logger:format_log(info, "FS_HANDLER(~p): Node ~p has gone down~n", [self(), Node]),
{noreply, State#state{fs_nodes=[N#node_handler{node_watch_pid=WatchPid} | lists:keydelete(Node, 2, Nodes)]}}
end;
handle_info(timeout, State) ->
spawn(fun() ->
{ok, Startup} = file:consult(?STARTUP_FILE),
Nodes = props:get_value(nodes, Startup, []),
lists:foreach(fun(Node) ->
add_fs_node(whistle_util:to_atom(Node, true))
end, Nodes)
end),
{noreply, State};
handle_info(_Info, State) ->
logger:format_log(info, "FS_HANDLER(~p): Unhandled Info: ~p~n", [self(), _Info]),
{noreply, State}.
Expand Down

0 comments on commit f549370

Please sign in to comment.