Get a random number.
:param int upper_bound: The upper bound. You will get a random number below this upper bound.
+
+.. function:: spawnThread(script)
+
+ .. versionadded:: 5.2.0
+
+ Spawn a thread.
+
+ :param str script: The pathname of the Lua script to run.
g_recCache->putRecords(data);
});
+ d_lw->writeFunction("spawnThread", [](const string& scriptName) {
+ auto log = g_slog->withName("lua")->withValues("name", Logging::Loggable(scriptName));
+ log->info(Logr::Info, "Starting Lua thread");
+ std::thread thread([=]() {
+ auto lua = std::make_shared<RecursorLua4>();
+ lua->loadFile(scriptName);
+ log->info(Logr::Notice, "Lua thread exiting");
+ });
+ thread.detach();
+ });
+
+
if (!d_include_path.empty()) {
includePath(d_include_path);
}
pdns::RateLimitedLog g_rateLimitedLogger;
+static void runCustomLua(Logr::log_t log);
+
static std::map<unsigned int, std::set<int>> parseCPUMap(Logr::log_t log)
{
std::map<unsigned int, std::set<int>> result;
_exit(1);
}
-static void setupNatsThread(Logr::log_t log)
-{
- log->info(Logr::Info, "Starting nats thread");
- std::thread thread([tid = std::this_thread::get_id(), log]() {
- auto lua = std::make_shared<RecursorLua4>();
- lua->loadFile("tmp/natsimpl.lua");
- log->info(Logr::Info, "Nats thread exited");
- });
- thread.detach();
-}
-
#ifdef NOD_ENABLED
static void setupNODThread(Logr::log_t log)
{
setupNODThread(log);
#endif /* NOD_ENABLED */
- setupNatsThread(log);
+ runCustomLua(log);
return RecThreadInfo::runThreads(log);
}
LockGuarded<pdns::rust::settings::rec::Recursorsettings> g_yamlStruct;
+static void runCustomLua(Logr::log_t log)
+{
+ auto settings = g_yamlStruct.lock();
+ const auto& script = settings->recursor.lua_startup_script;
+ if (script.empty()) {
+ return;
+ }
+ log->info(Logr::Info, "Starting Custom Lua", "script", Logging::Loggable(script));
+ //std::thread thread([=]() {
+ auto lua = std::make_shared<RecursorLua4>();
+ lua->loadFile(std::string(script));
+ log->info(Logr::Info, "Custom Lua done");
+ //});
+ //thread.detach();
+}
+
static void handleRuntimeDefaults(Logr::log_t log)
{
#ifdef HAVE_FIBER_SANITIZER
string buf;
for (const auto& recordSet : sidx) {
protozero::pbf_builder<PBCacheEntry> message(full, PBCacheDump::repeated_message_cacheEntry);
- cerr << "S " << count << ' ' << recordSet.d_qname << ' ' << QType(recordSet.d_qtype) << ' ' << recordSet.d_auth << ' ' << recordSet.d_records.size() << endl;
// Two fields below must come before the other fields
message.add_bytes(PBCacheEntry::required_bytes_name, recordSet.d_qname.toString());
message.add_uint32(PBCacheEntry::required_uint32_qtype, recordSet.d_qtype);
'skip-old' : 'Equivalent Lua config in :doc:`lua-config/proxymapping`',
'versionadded': '5.1.0',
},
+ {
+ 'name' : 'lua_startup_script',
+ 'section' : 'recursor',
+ 'type' : LType.String,
+ 'default' : '',
+ 'help' : 'Custom Lua script to run on startup',
+ 'doc' : '''
+Run this Lua script on startup in a separate thread.
+ ''',
+ 'skip-old' : 'No equivalent old-style setting',
+ 'versionadded': '5.2.0',
+ },
]