Commits

Kirill Korinskiy  committed 75cc21e

Rewrite start-loger logic

  • Participants
  • Parent commits 152355d

Comments (0)

Files changed (1)

     init(),
     riak_app:read_config(Config).    
 
+event_loger(Node, NodeName, Cookie, FileName) ->
+    init(),
+    net_kernel:start(NodeName),
+    case Cookie of
+	undefined ->
+	    ok;
+	_ ->
+	    erlang:set_cookie(node(), Cookie)
+    end,
+    case net_adm:ping(Node) of
+	pang ->
+	    io:format("Node ~s not avalible~n", [atom_to_list(Node)]);
+	pong ->
+	    riak_event_logger:start(Node, FileName),
+	    receive
+		_ -> ok
+	    end
+    end.
+    
+
 main(["start-fresh", Config]) ->
     init(Config),
     os:putenv("HEART_COMMAND", get_from_config(heart_command)),
 	    get_from_config(cookie), " ",
 	    get_from_config(sasl_logfile), " -run riak start ",
 	    Config, " -run riak_startup rejoin"]);
-main(["start-loger", Node])->
-    init(),
-    riak_event_logger:start(Node, "");
-main(["start-loger", Node, Cookie])->
-    init(),
-    erlang:set_cookie(node(), list_to_atom(Cookie)),
-    riak_event_logger:start(Node, "");
-main(["start-loger", Node, Cookie, FileName])->
-    init(),
-    erlang:set_cookie(node(), list_to_atom(Cookie)),
-    riak_event_logger:start(Node, FileName);
-main(["node-name"]) ->
-    init(),
-    io:format("~w~n", [node()]);
+main(["start-loger", "-sname", NodeName, Node, Cookie, Filename]) ->
+    event_loger(list_to_atom(Node), [list_to_atom(NodeName), shortnames],
+		list_to_atom(Cookie), Filename);
+main(["start-loger", "-name", NodeName, Node, Cookie, Filename]) ->
+    event_loger(list_to_atom(Node), [list_to_atom(NodeName)],
+		list_to_atom(Cookie), Filename);
+
+main(["start-loger", "-sname", NodeName, Node, Cookie]) ->
+    main(["start-loger", "-sname", NodeName, Node, Cookie, ""]);
+main(["start-loger", "-name", NodeName, Node, Cookie]) ->
+    main(["start-loger", "-name", NodeName, Node, Cookie, ""]);
+
+main(["start-loger", "-sname", NodeName, Node]) ->
+    main(["start-loger", "-sname", NodeName, Node, "undefined"]);
+main(["start-loger", "-name", NodeName, Node]) ->
+    main(["start-loger", "-name", NodeName, Node, "undefined"]);
+
+main(["start-loger", Node, Cookie, Filename]) ->
+    main(["start-loger", "-name", "riak-logger", Node, Cookie, Filename]);
+
+main(["start-loger", Node, Cookie]) ->
+    main(["start-loger", Node, Cookie, ""]);
+
+main(["start-loger", Node]) ->
+    main(["start-loger", Node, "nocookie"]);
+
 main(_)->
     usage().