couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From beno...@apache.org
Subject [33/50] couch commit: updated refs/remotes/origin/import to 09c6556
Date Mon, 10 Feb 2014 20:05:33 GMT
Rewrite restartServer() for robustness

This uses an instance wide token set in the application environment to
detect when the server has restarted.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/7035788d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/7035788d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/7035788d

Branch: refs/remotes/origin/import
Commit: 7035788d280b1ec4fe8d8406a558194043ae4c8d
Parents: 7047b89
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
Authored: Wed Mar 13 14:08:43 2013 -0500
Committer: Paul J. Davis <paul.joseph.davis@gmail.com>
Committed: Tue Feb 4 17:03:25 2014 -0600

----------------------------------------------------------------------
 src/couch_httpd_misc_handlers.erl | 11 +++++++++++
 1 file changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/7035788d/src/couch_httpd_misc_handlers.erl
----------------------------------------------------------------------
diff --git a/src/couch_httpd_misc_handlers.erl b/src/couch_httpd_misc_handlers.erl
index d57ceeb..3b2bbeb 100644
--- a/src/couch_httpd_misc_handlers.erl
+++ b/src/couch_httpd_misc_handlers.erl
@@ -94,6 +94,17 @@ handle_task_status_req(Req) ->
     send_method_not_allowed(Req, "GET,HEAD").
 
 
+handle_restart_req(#httpd{method='GET', path_parts=[_, <<"token">>]}=Req) ->
+    ok = couch_httpd:verify_is_server_admin(Req),
+    Token = case application:get_env(couch, instance_token) of
+        {ok, Tok} ->
+            Tok;
+        _ ->
+            Tok = erlang:phash2(make_ref()),
+            application:set_env(couch, instance_token, Tok),
+            Tok
+    end,
+    send_json(Req, 200, {[{token, Token}]});
 handle_restart_req(#httpd{method='POST'}=Req) ->
     couch_httpd:validate_ctype(Req, "application/json"),
     ok = couch_httpd:verify_is_server_admin(Req),


Mime
View raw message