summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Holley <willholley@gmail.com>2020-01-20 17:02:36 +0000
committerWill Holley <willholley@gmail.com>2020-01-21 08:03:00 +0000
commit6ec6f863117f0a321dbad72f01a80279b1391299 (patch)
treea18f26acc4978c494db3646b1d5e85bab5637a86
parent922ea4621ac9ccfa28e866f2fafb1dbf32c0f498 (diff)
downloadcouchdb-6ec6f863117f0a321dbad72f01a80279b1391299.tar.gz
Add POST /_node/<node>/_config/_reloadconfig_reload
Using the backend port 5986 it was possible to reload config from disk using the _config/_reload endpoint. This ports it to the _node API on the frontend cluster port.
-rw-r--r--src/chttpd/src/chttpd_node.erl10
-rw-r--r--test/elixir/test/config_test.exs7
2 files changed, 17 insertions, 0 deletions
diff --git a/src/chttpd/src/chttpd_node.erl b/src/chttpd/src/chttpd_node.erl
index 202070279..acd5affbd 100644
--- a/src/chttpd/src/chttpd_node.erl
+++ b/src/chttpd/src/chttpd_node.erl
@@ -46,6 +46,16 @@ handle_node_req(#httpd{method='GET', path_parts=[_, Node, <<"_config">>]}=Req) -
send_json(Req, 200, {KVs});
handle_node_req(#httpd{path_parts=[_, _Node, <<"_config">>]}=Req) ->
send_method_not_allowed(Req, "GET");
+% POST /_node/$node/_config/_reload - Flushes unpersisted config values from RAM
+handle_node_req(#httpd{method='POST', path_parts=[_, Node, <<"_config">>, <<"_reload">>]}=Req) ->
+ case call_node(Node, config, reload, []) of
+ ok ->
+ send_json(Req, 200, {[{ok, true}]});
+ {error, Reason} ->
+ chttpd:send_error(Req, {bad_request, Reason})
+ end;
+handle_node_req(#httpd{path_parts=[_, _Node, <<"_config">>, <<"_reload">>]}=Req) ->
+ send_method_not_allowed(Req, "POST");
% GET /_node/$node/_config/Section
handle_node_req(#httpd{method='GET', path_parts=[_, Node, <<"_config">>, Section]}=Req) ->
KVs = [{list_to_binary(Key), list_to_binary(Value)}
diff --git a/test/elixir/test/config_test.exs b/test/elixir/test/config_test.exs
index 2b2d71414..53c5bc82e 100644
--- a/test/elixir/test/config_test.exs
+++ b/test/elixir/test/config_test.exs
@@ -174,4 +174,11 @@ defmodule ConfigTest do
set_config(context, section, "wohali", "rules", 403)
end)
end
+
+ test "Reload config", context do
+ url = "#{context[:config_url]}/_reload"
+ resp = Couch.post(url)
+
+ assert resp.status_code == 200
+ end
end