From 3fedfaeb8d8413442c4bfd9944919269cb626024 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sun, 27 Sep 2020 14:44:33 -0700 Subject: [PATCH] ircd: Add conf item to convey contextual diagnostic options. --- construct/construct.cc | 5 +++++ include/ircd/ircd.h | 3 +++ ircd/ircd.cc | 15 +++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/construct/construct.cc b/construct/construct.cc index 1ccf4825f..eb0900eb1 100644 --- a/construct/construct.cc +++ b/construct/construct.cc @@ -46,6 +46,7 @@ bool nomatrix; bool matrix {true}; // matrix server by default. bool defaults; const char *bootstrap; +const char *diagnostic; lgetopt opts[] { @@ -80,6 +81,7 @@ lgetopt opts[] { "matrix", &matrix, lgetopt::BOOL, "Allow loading the matrix application module" }, { "defaults", &defaults, lgetopt::BOOL, "Use configuration defaults without database load for this execution" }, { "bootstrap", &bootstrap, lgetopt::STRING, "Bootstrap fresh database from event vector" }, + { "diagnostic", &diagnostic, lgetopt::STRING, "Specify a diagnostic type in conjunction with other commands" }, { nullptr, nullptr, lgetopt::STRING, nullptr }, }; @@ -477,6 +479,9 @@ enable_coredumps() void applyargs() { + if(diagnostic) + ircd::diagnostic.set(diagnostic); + if(single && !bootstrap) { ircd::write_avoid.set("true"); diff --git a/include/ircd/ircd.h b/include/ircd/ircd.h index bed3a6b23..8d72b6809 100644 --- a/include/ircd/ircd.h +++ b/include/ircd/ircd.h @@ -111,6 +111,9 @@ namespace ircd extern const info::versions version_api; extern const info::versions version_abi; + // Diagnostic Mode Options + extern conf::item diagnostic; + // Operating Mode Selectors extern conf::item restart; extern conf::item debugmode; diff --git a/ircd/ircd.cc b/ircd/ircd.cc index b26776e67..3be15db78 100644 --- a/ircd/ircd.cc +++ b/ircd/ircd.cc @@ -140,6 +140,21 @@ ircd::read_only } }; +/// Diagnostic options selection. This indicates whether any tests or special +/// behavior should occur rather than normal operation; also allowing for +/// fine-grained options to be conveyed to such tests/diagnostics. While this +/// appears here as coarse library-wide option it does not on its own affect +/// normal server operations just by being set. It affect things only if +/// specific functionality checks and alters its behavior based on the value +/// of this string contextually. +decltype(ircd::diagnostic) +ircd::diagnostic +{ + { "name", "ircd.diagnostic" }, + { "default", string_view{} }, + { "persist", false }, +}; + /// Main context pointer placement. decltype(ircd::main_context) ircd::main_context;