You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2014/02/10 21:22:55 UTC
[33/50] couch commit: updated refs/heads/import to 09c6556
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/heads/import
Commit: 7035788d280b1ec4fe8d8406a558194043ae4c8d
Parents: 7047b89
Author: Paul J. Davis <pa...@gmail.com>
Authored: Wed Mar 13 14:08:43 2013 -0500
Committer: Paul J. Davis <pa...@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),