0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-25 23:14:13 +01:00

Add -defaults program option to restore from broken configurations.

This commit is contained in:
Jason Volk 2020-04-24 21:26:06 -07:00
parent 71a0ec7532
commit 11f2eff4d9
5 changed files with 22 additions and 1 deletions

View file

@ -38,6 +38,7 @@ bool write_avoid;
bool soft_assert;
bool nomatrix;
bool matrix {true}; // matrix server by default.
bool defaults;
std::vector<std::string> execute;
std::array<bool, 7> smoketest;
@ -68,6 +69,7 @@ lgetopt opts[]
{ "sassert", &soft_assert, lgetopt::BOOL, "Softens assertion effects in debug mode."},
{ "nomatrix", &nomatrix, lgetopt::BOOL, "Prevent loading the matrix application module."},
{ "matrix", &matrix, lgetopt::BOOL, "Allow loading the matrix application module."},
{ "defaults", &defaults, lgetopt::BOOL, "Use configuration defaults without database load for this execution."},
{ nullptr, nullptr, lgetopt::STRING, nullptr },
};
@ -455,6 +457,9 @@ applyargs()
cmdline = true;
}
if(defaults)
ircd::defaults.set("true");
if(read_only)
ircd::read_only.set("true");

View file

@ -27,6 +27,13 @@ this simply replace the '.' characters with '_' in the name of the item when
setting it in the environment. The name is otherwise the same, including its
lower case.
Otherwise, the program can be run with the option `-defaults`. This will
prevent initial loading of the configuration from the database. It will
not prevent environmental variable overrides (as mentioned above). Values
will not be written back to the database unless they are explicitly set by
the user in the console.
##### Recovering from database corruption
In very rare cases after a hard crash the journal cannot completely restore

View file

@ -111,6 +111,7 @@ namespace ircd
extern conf::item<bool> read_only;
extern conf::item<bool> write_avoid;
extern conf::item<bool> soft_assert;
extern conf::item<bool> defaults;
// Informational
seconds uptime();

View file

@ -16,6 +16,14 @@ decltype(ircd::conf::on_init)
ircd::conf::on_init
{};
decltype(ircd::defaults)
ircd::defaults
{
{ "name", "ircd.defaults" },
{ "default", false },
{ "persist", false },
};
size_t
ircd::conf::reset()
{

View file

@ -256,7 +256,7 @@ ircd::m::homeserver::homeserver(const struct opts *const &opts)
if(primary == this)
vm = std::make_shared<vm::init>();
if(primary == this && conf)
if(primary == this && conf && !ircd::defaults)
conf->load();
if(primary == this && dbs::events && sequence(*dbs::events) == 0)