Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rec_control: add reload-lua-config option #4090

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions docs/manpages/rec_control.1.md
Expand Up @@ -109,8 +109,15 @@ quit-nicely
reload-acls
: Reloads ACLs.

reload-lua-script *FILENAME*
: (Re)loads Lua script *FILENAME*. This replaces the script currently loaded.
reload-lua-script [*FILENAME*]
: (Re)loads Lua script *FILENAME*. If *FILENAME* is empty, attempt to reload
the currently loaded script. This replaces the script currently loaded.

reload-lua-config [*FILENAME*]
: (Re)loads Lua configuration *FILENAME*. If *FILENAME* is empty, attempt to
reload the currently loaded file. Note that *FILENAME* will be fully executed,
any settings changed at runtime that are not modified in this file, will
still be active.

reload-zones
: Reload authoritative and forward zones. Retains current configuration
Expand Down
18 changes: 18 additions & 0 deletions pdns/rec_channel_rec.cc
Expand Up @@ -1103,6 +1103,7 @@ string RecursorControlParser::getAnswer(const string& question, RecursorControlP
"quit-nicely stop the recursor daemon nicely\n"
"reload-acls reload ACLS\n"
"reload-lua-script [filename] (re)load Lua script\n"
"reload-lua-config [filename] (re)load Lua configuration file\n"
"reload-zones reload all auth and forward zones\n"
"set-minimum-ttl value set minimum-ttl-override\n"
"set-carbon-server set a carbon server for telemetry\n"
Expand Down Expand Up @@ -1154,6 +1155,23 @@ string RecursorControlParser::getAnswer(const string& question, RecursorControlP
if(cmd=="reload-lua-script")
return doQueueReloadLuaScript(begin, end);

if(cmd=="reload-lua-config") {
if(begin != end)
::arg().set("lua-config-file") = *begin;

try {
loadRecursorLuaConfig(::arg()["lua-config-file"]);
L<<Logger::Warning<<"Reloaded Lua configuration file '"<<::arg()["lua-config-file"]<<"', requested via control channel"<<endl;
return "Reloaded Lua configuration file '"+::arg()["lua-config-file"]+"'\n";
}
catch(std::exception& e) {
return "Unable to load Lua script from '"+::arg()["lua-config-file"]+"': "+e.what()+"\n";
}
catch(const PDNSException& e) {
return "Unable to load Lua script from '"+::arg()["lua-config-file"]+"': "+e.reason+"\n";
}
}

if(cmd=="set-carbon-server")
return doSetCarbonServer(begin, end);

Expand Down