couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [20/23] couchdb-setup git commit: add finish cluster routine
Date Fri, 07 Nov 2014 14:46:44 GMT
add finish cluster routine


Project: http://git-wip-us.apache.org/repos/asf/couchdb-setup/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-setup/commit/354647bf
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-setup/tree/354647bf
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-setup/diff/354647bf

Branch: refs/heads/master
Commit: 354647bfaef652113ad033763658a42c45ba03d6
Parents: fc39fab
Author: Jan Lehnardt <jan@apache.org>
Authored: Fri Nov 7 15:34:54 2014 +0100
Committer: Jan Lehnardt <jan@apache.org>
Committed: Fri Nov 7 15:34:54 2014 +0100

----------------------------------------------------------------------
 src/setup.erl       | 18 +++++++++---------
 src/setup_httpd.erl |  8 +++++---
 2 files changed, 14 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-setup/blob/354647bf/src/setup.erl
----------------------------------------------------------------------
diff --git a/src/setup.erl b/src/setup.erl
index e5afb2a..781691e 100644
--- a/src/setup.erl
+++ b/src/setup.erl
@@ -46,12 +46,12 @@ is_cluster_enabled() ->
 has_cluster_system_dbs() ->
     % GET /_users /_replicator /_cassim
 
-    Users = fabric:get_db_info("_users"),
-    Replicator = fabric:get_db_info("_replicator"),
-    Cassim = fabric:get_db_info("_cassim"),
-    case {Users, Replicator, Cassim} of
+    case catch {
+    fabric:get_db_info("_users"),
+    fabric:get_db_info("_replicator"),
+    fabric:get_db_info("_cassim")} of
         {{ok, _}, {ok, _}, {ok, _}} -> ok;
-        _Else -> no
+        _ -> no
     end.
 
 enable_cluster(Options) ->
@@ -101,12 +101,12 @@ enable_cluster_int(Options, no) ->
 
 finish_cluster() ->
     finish_cluster_int(has_cluster_system_dbs()).
-finish_cluster_int(no) ->
-    {error, cluster_finished};
 finish_cluster_int(ok) ->
-    io:format("~nFinish Cluster~n").
+    {error, cluster_finished};
+finish_cluster_int(no) ->
     % create clustered databases (_users, _replicator, _cassim/_metadata
-    % am I in enabled mode, are there nodes?
+    Databases = ["_users", "_replicator", "_cassim"],
+    lists:foreach(fun fabric:create_db/1, Databases).
 
 
 add_node(Options) ->

http://git-wip-us.apache.org/repos/asf/couchdb-setup/blob/354647bf/src/setup_httpd.erl
----------------------------------------------------------------------
diff --git a/src/setup_httpd.erl b/src/setup_httpd.erl
index 550b04a..755b951 100644
--- a/src/setup_httpd.erl
+++ b/src/setup_httpd.erl
@@ -52,11 +52,13 @@ handle_action("enable_cluster", Setup) ->
 
 
 handle_action("finish_cluster", Setup) ->
-    io:format("~nfinish_cluster: ~p~n", [Setup]),
-    case etup:finish_cluster() of
+    io:format("~nffinish_cluster: ~p~n", [Setup]),
+    case setup:finish_cluster() of
         {error, cluster_finished} ->
             {error, <<"Cluster is already finished">>};
-        _ -> ok
+        Else ->
+            io:format("~nElse: ~p~n", [Else]),
+            ok
     end;
 
 handle_action("add_node", Setup) ->


Mime
View raw message