Permalink
Browse files

better behaviour on error during start and stop

SVN Revision: 254
  • Loading branch information...
1 parent 3c3299d commit 3b890beca60e076849f1e3d5a47cd8cc76b2205c @nniclausse nniclausse committed Mar 16, 2004
View
20 src/tsunami/ts_utils.erl
@@ -27,7 +27,7 @@
-export([debug/3, debug/4, get_val/1, init_seed/0, chop/1, elapsed/2,
now_sec/0, inet_setopts/4, node_to_hostname/1, add_time/2,
level2int/1, mkey1search/2, close_socket/2, datestr/0, datestr/1,
- erl_system_args/0, setsubdir/1]).
+ erl_system_args/0, setsubdir/1, stop_all/2, stop_all/3]).
level2int("debug") -> ?DEB;
level2int("info") -> ?INFO;
@@ -217,3 +217,21 @@ setsubdir(FileName) ->
{error, Err}
end.
+stop_all(Host, Name) ->
+ stop_all(Host, Name, "IDX-Tsunami").
+
+stop_all([Host],Name,MsgName) when atom(Host) ->
+ List= net_adm:world_list([Host]),
+ global:sync(),
+ case global:whereis_name('ts_mon') of
+ undefined ->
+ Msg = MsgName ++" is not running on " ++ atom_to_list(Host),
+ erlang:display(Msg);
+ Pid ->
+ Controller_Node = node(Pid),
+ slave:stop(Controller_Node)
+ end;
+stop_all(_,_,_)->
+ erlang:display("Bad Hostname").
+
+
View
16 src/tsunami_controller/tsunami_controller.erl
@@ -46,7 +46,12 @@ start(Type, _StartArgs) ->
end.
start_phase(load_config, StartType, PhaseArgs) ->
- ts_config_server:read_config(?config(config_file));
+ case ts_config_server:read_config(?config(config_file)) of
+ {error,Reason}->
+ erlang:display(["Config Error, aborting ! ", Reason]),
+ init:stop();
+ ok -> ok
+ end;
start_phase(start_os_monitoring, StartType, PhaseArgs) ->
ts_os_mon:activate();
start_phase(start_clients, StartType, PhaseArgs) ->
@@ -64,10 +69,5 @@ stop(State) ->
%% Func: stop_all/0
%% Returns: any
%%----------------------------------------------------------------------
-stop_all([Host]) ->
- List= net_adm:world_list([Host]),
- global:sync(),
- Pid = global:whereis_name('ts_mon'),
- Controller_Node = node(Pid),
- slave:stop(Controller_Node).
-
+stop_all(Arg) ->
+ ts_utils:stop_all(Arg,'ts_mon').
View
8 src/tsunami_recorder/tsunami_recorder.erl
@@ -62,9 +62,5 @@ stop(State) ->
%% Func: stop_all/0
%% Returns: any
%%----------------------------------------------------------------------
-stop_all([Host]) ->
- List= net_adm:world_list([Host]),
- global:sync(),
- Pid = global:whereis_name('ts_proxy_listener'),
- Controller_Node = node(Pid),
- slave:stop(Controller_Node).
+stop_all(Arg) ->
+ ts_utils:stop_all(Arg,'ts_proxy_listener', "IDX-Tsunami recorder").

0 comments on commit 3b890be

Please sign in to comment.