Commits

Anonymous committed c804506

Get rid of ip/doorbell/cookie connection scheme, use distributed Erlang. [#64]

Comments (0)

Files changed (19)

 # create a brand new riak ring, using configfile as app config params
 # run interactively, w/o heartbeat
 . riak-env.sh
-NODENAME=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~p~n\",[riak:get_app_env(riak_nodename)])" -run init stop)
-RHOSTNAME=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(riak_hostname)])" -run init stop)
-if [ "$NODENAME" = "no_riak_nodename_undefined" ]; then
-    echo "riak_nodename not set in config file, cannot start";
-else
-    exec erl -connect_all false -pa deps/*/ebin -pa ebin -name ${NODENAME}@${RHOSTNAME} -run riak start $1
-fi
+NODENAME=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(erlang_nodename)])" -run init stop)
+COOKIE=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(erlang_cookie)])" -run init stop)
+exec erl -connect_all false -pa deps/*/ebin -pa ebin -name ${NODENAME} -setcookie ${COOKIE} -run riak start $1
 # join an existing riak ring via a node known to be listening on ip:port
 # run in interactive debug shell mode
 . riak-env.sh
-NODENAME=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~p~n\",[riak:get_app_env(riak_nodename)])" -run init stop)
-RHOSTNAME=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(riak_hostname)])" -run init stop)
-if [ "$NODENAME" = "no_riak_nodename_undefined" ]; then
-    echo "riak_nodename not set in config file, cannot start";
-else
-    exec erl -connect_all false -pa deps/*/ebin -pa ebin -name ${NODENAME}@${RHOSTNAME} -run riak start $1 -run riak_startup join_cluster $2 $3
-fi
+NODENAME=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(erlang_nodename)])" -run init stop)
+COOKIE=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(erlang_cookie)])" -run init stop)
+exec erl -connect_all false -pa deps/*/ebin -pa ebin -name ${NODENAME} -setcookie ${COOKIE} -run riak start $1 -run riak_startup join_cluster $2
 # debug-restart <configfile>
 # assuming we've run a node from here before, start back up in debug mode
 . riak-env.sh
-NODENAME=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~p~n\",[riak:get_app_env(riak_nodename)])" -run init stop)
-RHOSTNAME=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(riak_hostname)])" -run init stop)
-if [ "$NODENAME" = "no_riak_nodename_undefined" ]; then
-    echo "riak_nodename not set in config file, cannot start";
-else
-    exec erl -connect_all false -pa deps/*/ebin -pa ebin -name ${NODENAME}@${RHOSTNAME} -run riak start $1 -run riak_startup rejoin
-fi
+NODENAME=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(erlang_nodename)])" -run init stop)
+COOKIE=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(erlang_cookie)])" -run init stop)
+exec erl -connect_all false -pa deps/*/ebin -pa ebin -name ${NODENAME} -setcookie ${COOKIE} -run riak start $1 -run riak_startup rejoin

src/jaywalker_resource.erl

             true ->
                 jiak:local_client();
             _ ->
-                jiak:client_connect(
-                  proplists:get_value(riak_ip, Props),
-                  proplists:get_value(riak_port, Props),
-                  proplists:get_value(riak_cookie, Props))
+                Node = proplists:get_value(riak_node),
+                Cookie = proplists:get_value(riak_cookie),
+                erlang:set_cookie(node(), Cookie),
+                jiak:client_connect(Node)
         end,
     {ok, #ctx{cache_secs=proplists:get_value(cache_secs, Props, 600),
               jiak_client=JiakClient}}.

src/jiak_resource.erl

             true ->
                 jiak:local_client();
             _ ->
-                jiak:client_connect(
-                  proplists:get_value(riak_ip, Props),
-                  proplists:get_value(riak_port, Props),
-                  proplists:get_value(riak_cookie, Props))
+                Node = proplists:get_value(riak_node),
+                Cookie = proplists:get_value(riak_cookie),
+                erlang:set_cookie(node(), Cookie),
+                jiak:client_connect(Node)
         end,
     {ok, #ctx{jiak_name=proplists:get_value(jiak_name, Props),
               key=proplists:get_value(key_type, Props),
 -author('Bryan Fink <bryan@basho.com>').
 -export([start/0, start/1, stop/0, stop/1]).
 -export([get_app_env/1,get_app_env/2]).
--export([client_connect/3,client_connect/4,local_client/0]).
+-export([client_connect/1,local_client/0]).
 
 -include_lib("eunit/include/eunit.hrl").
 
 
 %% @spec local_client() -> {ok, Client :: riak_client()}
 %% @doc When you want a client for use on a running Riak node.
-local_client() -> {ok, riak_client:new(node(), riak_util:mkclientid(node()))}.
+local_client() -> client_connect(node()).
 
-%% @spec client_connect(IP :: list(), Port :: integer(), RiakCookie :: atom())
+
+%% @spec client_connect(Node :: node())
 %%        -> {ok, Client :: riak_client()} | {error, timeout}
 %% @doc The usual way to get a client.  Timeout often means either a bad
 %%      cookie or a poorly-connected distributed erlang network.
-client_connect(IP,Port,RiakCookie) -> client_connect(IP,Port,RiakCookie,1000).
+client_connect(Node) -> 
+    % Make sure we can reach this node...
+    try pong = net_adm:ping(Node)
+    catch _ : _ -> throw({could_not_reach_node, Node}) end,
+        
+    % Return the newly created node...
+    {ok, riak_client:new(Node, riak_util:mkclientid(Node))}.
 
-%% @spec client_connect(IP :: list(), Port :: integer(), RiakCookie :: atom(),
-%%                      TimeoutMillisecs :: integer())
-%%        -> {ok, Client :: riak_client()} | {error, timeout}
-%% @doc The usual way to get a client.  Timeout often means either a bad
-%%      cookie or a poorly-connected distributed erlang network.
-client_connect(IP,Port,RiakCookie,Timeout)
-  when is_list(IP),is_integer(Port),is_atom(RiakCookie),is_integer(Timeout) ->
-    Nonce = riak_doorbell:knock(IP,Port,RiakCookie),
-    receive
-        {riak_connect, Nonce, Node} ->
-            {ok, riak_client:new(Node, riak_util:mkclientid(Node))}
-    after
-        Timeout ->
-            {error, timeout}
-    end.
 
 %% @spec ensure_started(Application :: atom()) -> ok
 %% @doc Start the named application if not already started.
 	    ok;
 	{error, {already_started, App}} ->
 	    ok
-    end.
-	
-local_client_test() ->
-    Node = node(),
-    {ok, {riak_client, Node, _ClientId}} = riak:local_client().
-
-remote_client_test() ->
-    application:set_env(riak, doorbell_port, 9002),   
-    application:set_env(riak, riak_cookie, remote_client_test),
-    riak_doorbell:start_link(),
-    {ok, {riak_client, _, _}} = riak:client_connect("127.0.0.1", 9002, 
-                                                    remote_client_test),
-    riak_doorbell:stop().
+    end.
         _ -> read_config()
     end,
     register(riak_app, self()),
-    erlang:set_cookie(node(), riak:get_app_env(riak_cookie)),
     riak_sup:start_link().
 
 %% @spec stop(State :: term()) -> ok
     % set some defaults for undefined fields
     [ClusterName,RingStateDir,RingCreationSize,
      WantsClaimFun,ChooseClaimFun,GossipInterval,
-     DoorbellPort,StorageBackend,RiakCookie,RiakAddPaths,
-     RiakNodeName,RiakHostName,RiakHeartCommand,
+     StorageBackend,RiakAddPaths, RiakHeartCommand,
      DefaultBucketProps,RiakStartApps] =
         [riak:get_app_env(X) || X <- 
            [cluster_name,ring_state_dir,ring_creation_size,
             wants_claim_fun,choose_claim_fun,gossip_interval,
-            doorbell_port,storage_backend,riak_cookie,add_paths,
-            riak_nodename,riak_hostname,riak_heart_command,
+            storage_backend,add_paths, riak_heart_command,
             default_bucket_props,start_apps]],
     if
         ClusterName =:= undefined ->
         true -> ok
     end,
     if
-        DoorbellPort =:= undefined ->
-            io_lib:format(
-                  "doorbell_port unset in ~p, no UDP service.",[ConfigPath]);
-        is_integer(DoorbellPort) =:= false ->
-            riak:stop(io_lib:format(
-                "doorbell_port set to ~p in ~p, must be integer",
-                          [DoorbellPort,ConfigPath]));
-        true -> ok
-    end,
-    if
         StorageBackend =:= undefined ->
             nop; % but you had better know what you're doing!
         not is_atom(StorageBackend) ->
         true -> ok
     end,
     if
-        RiakCookie =:= undefined ->
-            riak:stop(io_lib:format(
-                       "riak_cookie unset in ~p, failing.",[ConfigPath]));
-        not is_atom(RiakCookie) ->
-            riak:stop(io_lib:format(
-                       "riak_cookie in ~p non-atom, failing.",[ConfigPath]));
-        true -> ok
-    end,
-    if
         RiakAddPaths =:= undefined ->
             error_logger:info_msg(
               "add_paths unset in ~p, setting to []~n",
         true -> ok
     end,
     if
-        % this one has to stop hard, as we test it before starting the app
-        RiakNodeName =:= undefined ->
-            io:format("no_riak_nodename_"),
-            init:stop();
-        not is_atom(RiakNodeName) ->
-            io:format("no_riak_nodename_"),
-            init:stop();
-        true -> ok
-    end,
-    if
-        % this one has to stop hard, as we test it before starting the app
-        RiakHostName =:= undefined ->
-            io:format("no_riak_hostname_"),
-            init:stop();
-        not is_list(RiakHostName) ->
-            io:format("no_riak_hostname_"),
-            init:stop();
-        true -> ok
-    end,
-    if
         RiakHeartCommand =:= undefined ->
             application:set_env(riak, riak_heart_command, "fail_to_restart");
         not is_list(RiakHeartCommand) ->
 %% @doc Configure/prep a node to perform backup for Cluster, using CookieStr.
 %%      The argument is a list of the form
 %%      [Cluster :atom(), CookieStr :: list()].
-dump_config([Cluster, CookieStr]) ->
+dump_config([Cluster]) ->
     RipConf = [{no_config, true}, {cluster_name, Cluster},
-       {riak_cookie, list_to_atom(CookieStr)}, {ring_state_dir, "<nostore>"},
+       {ring_state_dir, "<nostore>"},
        {ring_creation_size, 12}, {gossip_interval, 1000},
        {wants_claim_fun, {riak_claim, never_wants_claim}},
-       {doorbell_port, undefined}, {storage_backend, undefined}],
+       {storage_backend, undefined}],
     backup_config(RipConf).
 
 %% @type restore_config_params() = list()
 %% @doc Configure/prep a node to perform restore for Cluster, using CookieStr.
 %%      The argument is a list of the form
 %%      [Cluster :: atom(), CookieStr :: list()].
-restore_config([Cluster, CookieStr]) ->
+restore_config([Cluster]) ->
     TempDir = make_tmp_dir(),
     RipConf = [{no_config, true}, {cluster_name, Cluster},
-       {riak_cookie, list_to_atom(CookieStr)}, {ring_state_dir, "<nostore>"},
+       {ring_state_dir, "<nostore>"},
        {ring_creation_size, 12}, {gossip_interval, 60000},
        {wants_claim_fun, {riak_claim, never_wants_claim}},
-       {riak_web_ip, "undefined"}, {doorbell_port, undefined},{backup, true},
+       {riak_web_ip, "undefined"}, {backup, true},
        {riak_fs_backend_root, filename:join(TempDir, "storage")},
        {storage_backend, undefined}],
     backup_config(RipConf).
 %% @doc Connect to the cluster via IP:PortStr, and make a dumpfile at Filename.
 %%      The argument is a list of the form
 %%      [IP :: list(), PortStr :: list(), Filename :: list()].
-do_dump([IP, PortStr, Filename]) ->
+do_dump([Node, Filename]) when is_list(Node) -> do_dump([list_to_atom(Node), Filename]);
+do_dump([Node, Filename]) ->
     ReqID = erlang:phash2({random:uniform(), self()}),
     io:format("starting dump ID ~p~n", [ReqID]),
-    riak_startup:join_cluster([IP, PortStr]),
+    riak_startup:join_cluster(Node),
+    timer:sleep(5 * 1000),
     All_I_VN = lists:flatten(
-          [gen_server:call({riak_vnode_master, Node},all_possible_vnodes) ||
-                  Node <- nodes()]),
+          [gen_server:call({riak_vnode_master, X},all_possible_vnodes) ||
+                  X <- nodes()]),
     IV_Lists = [{I, VN, gen_server2:call(VN,list)} || {I,VN} <- All_I_VN],
     {ok, dumptable} = dets:open_file(dumptable, [{file, Filename}]),
     dump_records(IV_Lists),
 %%      Note that this reconciles instead of blindly overwriting.
 %%      The argument is a list of the form
 %%      [IP :: list(), PortStr :: list(), Cookie :: list(), Filename :: list()].
-do_restore([IP, PortStr, Cookie, Filename]) ->
+do_restore([Node, Filename]) when is_list(Node) -> do_restore([list_to_atom(Node), Filename]);
+do_restore([Node, Filename]) ->
     ReqID = erlang:phash2({random:uniform(), self()}),
     io:format("starting restore ID ~p~n", [ReqID]),
     {ok, r_table} = dets:open_file(r_table, [{file, Filename}]),
-    {ok, Client} = riak:client_connect(IP,list_to_integer(PortStr),list_to_atom(Cookie)),
+    {ok, Client} = riak:client_connect(Node),
     Trav = dets:traverse(r_table,
       fun({{Bucket,Key},V}) ->
               RObj0 = binary_to_term(V),
 -export ([send_ring/1, send_ring/2, remove_from_cluster/1]).
 
 -include_lib("eunit/include/eunit.hrl").
+-define (SERVER, ?MODULE).
 
 %% send_ring/1 -
 %% Send the current node's ring to some other node.
             BalancedRing = claim_until_balanced(ReconciledRing),
             riak_ring_manager:set_my_ring(BalancedRing),
             RandomNode = riak_ring:random_node(BalancedRing),
-            send_ring(self(), RandomNode),
+            send_ring(node(), RandomNode),
             riak_eventer:notify(riak_connect, changed_ring, gossip_changed),
             {noreply, true}
     end;

src/riak_doorbell.erl

-%% This file is provided to you under the Apache License,
-%% Version 2.0 (the "License"); you may not use this file
-%% except in compliance with the License.  You may obtain
-%% a copy of the License at
-
-%%   http://www.apache.org/licenses/LICENSE-2.0
-
-%% Unless required by applicable law or agreed to in writing,
-%% software distributed under the License is distributed on an
-%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-%% KIND, either express or implied.  See the License for the
-%% specific language governing permissions and limitations
-%% under the License.    
-
-%% @doc The doorbell (and door knocker) is a UDP socket server that provides a discovery mechanism for other nodes to connect into the Riak cluster.
-
--module(riak_doorbell).
-
--behaviour(gen_server).
--export([start_link/0]).
--export([init/1, handle_call/3, handle_cast/2, handle_info/2,
-	 terminate/2, code_change/3]).
--export([ring/2,knock/3, stop/0]).
-
--include_lib("eunit/include/eunit.hrl").
-	 
--record(state, {port, sock}).
-
-%% @spec start_link() -> {ok, pid()}
-start_link() ->
-    Port = riak:get_app_env(doorbell_port),
-    pong = net_adm:ping(node()), % fail if not distributed
-    gen_server:start_link({local, ?MODULE}, ?MODULE, [Port], []).
-
-%% @spec knock(IP :: list(), Port :: integer(), RiakCookie :: atom()) ->
-%%       ok | {error, Reason}
-%% @doc This is used by a node not seeking to be a member of the cluster,
-%%      to establish a distributed-erlang connection used by a riak_client.
-knock(IP, Port, RiakCookie) ->
-    % for non-riak nodes seeking a client proc
-    Nonce = random:uniform(),
-    {ok, SendSock} = gen_udp:open(0),
-    gen_udp:send(SendSock, IP, Port,term_to_binary({
-              {knock,Nonce,self(),erlang:get_cookie(),RiakCookie},node()})),
-    gen_udp:close(SendSock),
-    Nonce.
-
-%% @spec ring(IP :: list(), Port :: integer()) ->
-%%       ok | {error, Reason}
-%% @doc This is used by a node joining the riak cluster.
-ring(IP, Port) ->
-    % for riak nodes joining
-    {ok, SendSock} = gen_udp:open(0),
-    Res = gen_udp:send(SendSock, IP, Port, term_to_binary({ring,node()})),
-    gen_udp:close(SendSock),
-    Res.
-
-stop() -> gen_server:cast(?MODULE, stop).
-    
-% @private
-init([Port]) ->
-    Opts = [{active, true},
-            list,
-            {reuseaddr, true}],
-    {ok, Sock} = gen_udp:open(Port, Opts),
-    {ok, #state{port=Port,sock=Sock}}.
-
-% @private
-handle_info({udp, _Socket, IP, _InPortNo, Packet0},State) ->
-    {RingType, Node} = binary_to_term(list_to_binary(Packet0)),
-    case RingType of
-        ring ->
-            case net_adm:ping(Node) of
-                pong -> riak_eventer:notify(riak_doorbell,connected,{IP,Node});
-                pang -> riak_eventer:notify(riak_doorbell,connectfail,{IP,Node})
-            end;
-        {knock,Nonce,Pid,Cookie,RiakCookie} ->
-            case riak:get_app_env(riak_cookie) of
-                RiakCookie ->
-                    riak_eventer:notify(riak_doorbell, client_connected,
-                                        {IP, Pid, Node}),
-                    erlang:set_cookie(Node,Cookie),
-                    Pid ! {riak_connect, Nonce, node()};
-                _ ->
-                    riak_eventer:notify(riak_doorbell, client_connectfail,
-                                        {IP, Pid, Node})
-            end
-    end,
-    {noreply, State};
-handle_info(_Info, State) -> {noreply, State}.
-
-%% @private
-handle_cast(stop, State) -> {stop, normal,State}.
-
-%% @private
-handle_call(_Request, _From, State) -> {reply, no_call, State}.
-
-%% @private
-terminate(_Reason, _State=#state{sock=Sock}) ->
-    gen_udp:close(Sock),
-    ok.
-
-%% @private
-code_change(_OldVsn, State, _Extra) ->  {ok, State}.
-
-knock_test() ->
-    application:set_env(riak, doorbell_port, 9001),
-    application:set_env(riak, riak_cookie, default_riak_cookie),
-    {ok, _Pid} = riak_doorbell:start_link(),
-    Nonce = riak_doorbell:knock("127.0.0.1", 9001, default_riak_cookie),
-    receive
-        {riak_connect, Nonce, _} ->
-            ok
-    after 1000 ->
-            throw(knock_test_timeout)
-    end,
-    riak_doorbell:stop().
-       
-    
-            
-    
-
-    
-

src/riak_event_logger.erl

 
 
 register_for_events(State) ->
-    io:format("1~n"),
     {ok, C} = riak:client_connect(State#state.hostname, State#state.port, State#state.cookie),
-    io:format("2~n"),
     Desc = io_lib:format("~s (~s)", [?SERVER, node()]),
-    io:format("3~n"),
-    C:add_event_handler(self(), Desc),
-    io:format("4~n").
+    C:add_event_handler(self(), Desc).
 
 
 %%% DATE FUNCTIONS %%%
 -module(riak_startup).
 -export([initiate_cluster/0,join_cluster/1,rejoin/0,no_config/0]).
 
-% functions called by the shell scripts used to start riak
-
-% How do we know when a node is successfully running in a cluster.
-%
-%
-% start(ConfigFile) ->
-%     % try_join()
-%     % Read the config file.
-%     % Read riak_clustername, riak_seednodes, riak_cookie, ring_location
-%     % Set riak_cookie on local node.
-%     % Try to get the ring from each seed node.
-%     % If it worked then we're done. Read cluster_name and gossip_interval from other node.
-%     
-%     % try_restart()
-%     % Try to read the local ring file.
-%      
-%     % try_fresh()
-%     % Read ring_creation_size and gossip_interval
-%     % Create a new ring
-% 
-% try_join(_, []) -> could_not_connect;
-% try_join(ClusterName, [SeedNode|SeedNodes]) ->
-%     
-%     riak_ring_gossiper:get_ring_from(hd(nodes()));
-    
-    
-    
-
-join_cluster([IP, PortStr]) ->
+join_cluster([Node]) when is_list(Node) -> join_cluster(list_to_atom(Node));
+join_cluster(Node) ->
     case check_deps() of
         ok ->
-            Port = list_to_integer(PortStr),
-            riak_doorbell:ring(IP, Port),
-            timer:sleep(1000),
-            riak_connect:send_ring(hd(nodes()), node());
+            riak_connect:send_ring(Node, node());
         X ->
             X
     end.
 -export([start_link/0]).
 -export([init/1]).
 
+-define (IF (Bool, A, B), if Bool -> A; true -> B end).
+
 %% @spec start_link() -> ServerRet
 %% @doc API for starting the supervisor.
 start_link() ->
     Eventer = {riak_eventer,
                {riak_eventer, start_link, []},
                permanent, 5000, worker, [riak_eventer]},
-    Doorbell = {riak_doorbell,
-                {riak_doorbell, start_link, []},
-                permanent, 5000, worker, [riak_doorbell]},
+    VMaster = {riak_vnode_master,
+               {riak_vnode_master, start_link, []},
+               permanent, 5000, worker, [riak_vnode_master]},
     RingMgr = {riak_ring_manager,
              {riak_ring_manager, start_link, []},
              permanent, 5000, worker, [riak_ring_manager]},
     Connect = {riak_connect,
              {riak_connect, start_link, []},
              permanent, 5000, worker, [riak_connect]},
-    VMaster = {riak_vnode_master,
-               {riak_vnode_master, start_link, []},
-               permanent, 5000, worker, [riak_vnode_master]},
     LocalLogger = {riak_local_logger,
                    {riak_local_logger, start_link, []},
                    permanent, 5000, worker, [riak_local_logger]},
     RiakWeb = {webmachine_mochiweb,
                  {webmachine_mochiweb, start, [riak_web:config()]},
                   permanent, 5000, worker, dynamic},
-    Processes0 = 
-    case riak:get_app_env(riak_web_ip) of
-        "undefined" ->
-            [RingMgr,Connect,LocalLogger];
-        undefined ->
-            [RingMgr,Connect,LocalLogger];
-        _ ->
-            [RingMgr,Connect,LocalLogger,
-             RiakWeb]
-    end,
-    Processes1 = 
-    case riak:get_app_env(doorbell_port) of
-        "undefined" -> Processes0;
-        undefined -> Processes0;
-        _ -> [Doorbell|Processes0]
-    end,
-    Processes2 = 
-    case riak:get_app_env(storage_backend) of
-        "undefined" -> Processes1;
-        undefined -> Processes1;
-        _ -> [VMaster|Processes1]
-    end,
-    Processes = [Eventer|Processes2],
+    
+    % Figure out which processes we should run...
+    IsWebConfigured = (riak:get_app_env(riak_web_ip) /= undefined) andalso (riak:get_app_env(riak_web_ip) /= "undefined"),
+    HasStorageBackend = (riak:get_app_env(storage_backend) /= undefined) andalso (riak:get_app_env(storage_backend) /= "undefined"),
+    
+    % Build the process list...
+    Processes = lists:flatten([
+        Eventer,
+        ?IF(HasStorageBackend, VMaster, []),
+        RingMgr, 
+        Connect, 
+        LocalLogger,
+        ?IF(IsWebConfigured, RiakWeb, [])
+    ]),
+    
+    % Run the proesses...
     {ok, {{one_for_one, 10, 10}, Processes}}.
 
 local_reconcile(K,RemObj,Mod,ModState,IsBackup) ->
     FinalObj = case IsBackup of
-     true -> RemObj;
-     false ->
-       case Mod:get(ModState,K) of
-           {ok,V} -> riak_object:reconcile([binary_to_term(V),RemObj],false);
-           _ -> RemObj
-       end
+        true -> RemObj;
+        false ->
+            case Mod:get(ModState,K) of
+                {ok,V} -> riak_object:reconcile([binary_to_term(V),RemObj],false);
+                _ -> RemObj
+            end
     end,
     case Mod:put(ModState, K, term_to_binary(FinalObj, [compressed])) of
         ok ->
 #!/usr/bin/env bash
-# ./start-backup-dump.sh <clustername> <cookie> <ip> <port> <dumpfilename>
+# ./start-backup-dump.sh <clustername> <node> <cookie> <filename>
+#
 # This will:
-#  Join riak cluster <clustername> using erlcookie <cookie>
-#  via the node listening at <ip>:<port>
-#  and dump the entire cluster's contents to <dumpfilename>
-if [ $# -lt 5 ]; then
+#  1. Join riak cluster <clustername> at <node> using <cookie>
+#  2. Dump the entire cluster's contents to <filename>
+if [ $# -lt 4 ]; then
     echo Usage: 1>&2
-    echo "    `basename $0` <clustername> <cookie> <ip in ring> " 1>&2
-    echo "                  <doorbell port> <filename to save dump to>" 1>&2
+    echo "    `basename $0` <clustername> <node> <cookie> <filename>" 1>&2
     exit 1
 fi
 . riak-env.sh
-erl -noshell -pa deps/*/ebin -pa ebin -name backup_dumper -run riak_backup dump_config $1 $2 -run riak start -run riak_backup do_dump $3 $4 $5 -run init stop
+CLUSTERNAME=$1
+NODE=$2
+COOKIE=$3
+FILENAME=$4
+erl -noshell -pa deps/*/ebin -pa ebin -name backup_dumper -setcookie $COOKIE -run riak_backup dump_config $CLUSTERNAME -run riak start -run riak_backup do_dump $NODE $FILENAME -run init stop

start-backup-restore.sh

 #!/usr/bin/env bash
-# ./start-backup-restore.sh <clustername> <cookie> <ip> <port> <dumpfilename>
+# ./start-backup-restore.sh <clustername> <node> <cookie> <filename>
 # This will:
-#  Join riak cluster <clustername> using erlcookie <cookie>
-#  via the node listening at <ip>:<port>
-#  and overwrite cluster data with that contained in <dumpfilename>
-if [ $# -lt 5 ]; then
+#  1. Join riak cluster <clustername> at <node> using <cookie>
+#  2. Overwrite cluster data with data contained in <filename>
+if [ $# -lt 4 ]; then
     echo Usage: 1>&2
-    echo "    `basename $0` <clustername> <cookie> <ip in ring> " 1>&2
-    echo "                  <doorbell port> <filename to restore from>" 1>&2
+    echo "    `basename $0` <clustername> <node> <cookie> <filename>" 1>&2
     exit 1
 fi
 . riak-env.sh
-erl -noshell -pa deps/*/ebin -pa ebin -name backup_restore -run riak_backup restore_config $1 $2 -run riak start -run riak_backup do_restore $3 $4 $2 $5 -run init stop
+CLUSTERNAME=$1
+NODE=$2
+COOKIE=$3
+FILENAME=$4
+erl -noshell -pa deps/*/ebin -pa ebin -name backup_restore -setcookie $COOKIE -run riak_backup restore_config $CLUSTERNAME -run riak start -run riak_backup do_restore $NODE $FILENAME -run init stop
 
 # start-fresh <configfile>
 # create a brand new riak ring, using configfile as app config params
 . riak-env.sh
-NODENAME=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~p~n\",[riak:get_app_env(riak_nodename)])" -run init stop)
-RHOSTNAME=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(riak_hostname)])" -run init stop)
+NODENAME=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(erlang_nodename)])" -run init stop)
+COOKIE=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(erlang_cookie)])" -run init stop)
 export HEART_COMMAND=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(riak_heart_command)])" -run init stop)
-if [ "$NODENAME" = "no_riak_nodename_undefined" ]; then
-    echo "riak_nodename not set in config file, cannot start";
-else
-    exec erl -heart -detached -connect_all false -pa deps/*/ebin -pa ebin -name ${NODENAME}@${RHOSTNAME} -run riak start $1
-fi
+exec erl -heart -detached -connect_all false -pa deps/*/ebin -pa ebin -name ${NODENAME} -setcookie ${COOKIE} -run riak start $1
 #!/usr/bin/env bash
 # start-join <configfile> <ip> <port>
 # join an existing riak ring via a node known to be listening on ip:port
-if [ $# -lt 3 ]; then
+if [ $# -lt 2 ]; then
     echo Usage: 1>&2
-    echo "    `basename $0` <config file> <ip of node in ring> <doorbell port>" 1>&2
+    echo "    `basename $0` <config file> Node" 1>&2
     exit 1
 fi
 . riak-env.sh
-NODENAME=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~p~n\",[riak:get_app_env(riak_nodename)])" -run init stop)
-RHOSTNAME=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(riak_hostname)])" -run init stop)
+NODENAME=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(erlang_nodename)])" -run init stop)
+COOKIE=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(erlang_cookie)])" -run init stop)
 export HEART_COMMAND=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(riak_heart_command)])" -run init stop)
-if [ "$NODENAME" = "no_riak_nodename_undefined" ]; then
-    echo "riak_nodename not set in config file, cannot start";
-else
-    exec erl -heart -detached -connect_all false -pa deps/*/ebin -pa ebin -name ${NODENAME}@${RHOSTNAME} -run riak start $1 -run riak_startup join_cluster $2 $3
-fi
+exec erl -heart -detached -connect_all false -pa deps/*/ebin -pa ebin -name ${NODENAME} -setcookie ${COOKIE} -run riak start $1 -run riak_startup join_cluster $2
 # assuming we've run a node from here before, start back up
 . riak-env.sh
 echo $ERL_MAX_ETS_TABLES
-NODENAME=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~p~n\",[riak:get_app_env(riak_nodename)])" -run init stop)
-RHOSTNAME=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(riak_hostname)])" -run init stop)
+NODENAME=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(erlang_nodename)])" -run init stop)
+COOKIE=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(erlang_cookie)])" -run init stop)
 export HEART_COMMAND=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(riak_heart_command)])" -run init stop)
-if [ "$NODENAME" = "no_riak_nodename_undefined" ]; then
-    echo "riak_nodename not set in config file, cannot start";
-else
-    exec erl -heart -detached -connect_all false -pa deps/*/ebin -pa ebin -name ${NODENAME}@${RHOSTNAME} -run riak start $1 -run riak_startup rejoin
-fi
+exec erl -heart -detached -connect_all false -pa deps/*/ebin -pa ebin -name ${NODENAME} -setcookie ${COOKIE} -run riak start $1 -run riak_startup rejoin