You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by wi...@apache.org on 2020/01/20 17:05:46 UTC

[couchdb] branch config_reload created (now b4143d0)

This is an automated email from the ASF dual-hosted git repository.

willholley pushed a change to branch config_reload
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


      at b4143d0  Add POST /_node/<node>/_config/_reload

This branch includes the following new commits:

     new b4143d0  Add POST /_node/<node>/_config/_reload

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[couchdb] 01/01: Add POST /_node//_config/_reload

Posted by wi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

willholley pushed a commit to branch config_reload
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit b4143d03ef1a83855ee7c6221668fbf03f9d7b66
Author: Will Holley <wi...@gmail.com>
AuthorDate: Mon Jan 20 17:02:36 2020 +0000

    Add POST /_node/<node>/_config/_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.
---
 src/chttpd/src/chttpd_node.erl   | 8 ++++++++
 test/elixir/test/config_test.exs | 7 +++++++
 2 files changed, 15 insertions(+)

diff --git a/src/chttpd/src/chttpd_node.erl b/src/chttpd/src/chttpd_node.erl
index 2020702..391cb5e 100644
--- a/src/chttpd/src/chttpd_node.erl
+++ b/src/chttpd/src/chttpd_node.erl
@@ -46,6 +46,14 @@ 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;
 % 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 2b2d714..53c5bc8 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