diff --git a/construct/construct.cc b/construct/construct.cc index fa6507e5a..77ae2ea56 100644 --- a/construct/construct.cc +++ b/construct/construct.cc @@ -38,7 +38,6 @@ bool yes6; bool norun; bool nomain; bool read_only; -bool write_avoid; bool slave; std::array smoketest; bool megatest; @@ -76,7 +75,6 @@ lgetopt opts[] { "norun", &norun, lgetopt::BOOL, "[debug] Initialize but never run the event loop" }, { "nomain", &nomain, lgetopt::BOOL, "[debug] Initialize and run without entering ircd::main()" }, { "ro", &read_only, lgetopt::BOOL, "Read-only mode. No writes to database allowed" }, - { "wa", &write_avoid, lgetopt::BOOL, "Like read-only mode, but writes permitted if triggered" }, { "slave", &slave, lgetopt::BOOL, "Like read-only mode; allows multiple instances of server" }, { "smoketest", &smoketest[0], lgetopt::BOOL, "Starts and stops the daemon to return success" }, { "megatest", &megatest, lgetopt::BOOL, "Trap execution every millionth tick for diagnostic and statistics." }, @@ -558,10 +556,11 @@ applyargs() ircd::db::auto_deletion.set("false"); } - if(single && !bootstrap) + if(single) { - ircd::write_avoid.set("true"); + ircd::maintenance.set("true"); cmdline = !debugmode; + nobackfill = true; } if(bootstrap) @@ -577,16 +576,7 @@ applyargs() } if(read_only) - { ircd::read_only.set("true"); - write_avoid = true; // read_only implies write_avoid. - } - - if(write_avoid) - { - ircd::write_avoid.set("true"); - nobackfill = true; - } if(debugmode) ircd::debugmode.set("true"); diff --git a/include/ircd/ircd.h b/include/ircd/ircd.h index b25520d52..50fbb2d4a 100644 --- a/include/ircd/ircd.h +++ b/include/ircd/ircd.h @@ -131,7 +131,6 @@ namespace ircd extern conf::item debugmode; extern conf::item maintenance; extern conf::item soft_assert; - extern conf::item write_avoid; // implies maintenance extern conf::item read_only; // implies write_avoid extern conf::item defaults; } diff --git a/ircd/db.cc b/ircd/db.cc index dad79f5d8..7a17ab8d0 100644 --- a/ircd/db.cc +++ b/ircd/db.cc @@ -179,10 +179,10 @@ try fs::base::db }; - if(!fs::is_dir(dbdir) && (ircd::read_only || ircd::write_avoid)) + if(!fs::is_dir(dbdir) && (ircd::read_only || ircd::maintenance)) log::warning { - log, "Not creating database directory `%s' in read-only/write-avoid mode.", dbdir + log, "Not creating database directory `%s' in read-only/maintenance mode.", dbdir }; else if(fs::mkdir(dbdir)) log::notice diff --git a/ircd/db_database.cc b/ircd/db_database.cc index 5095e8fa7..266fafb69 100644 --- a/ircd/db_database.cc +++ b/ircd/db_database.cc @@ -1297,7 +1297,7 @@ try // If the directory does not exist, though rocksdb will create it, we can // avoid scaring the user with an error log message if we just do that.. - if(opts->create_if_missing && !fs::is_dir(path) && !ircd::write_avoid) + if(opts->create_if_missing && !fs::is_dir(path) && !ircd::maintenance && !ircd::read_only) fs::mkdir(path); // Announce attempt before usual point where exceptions are thrown diff --git a/ircd/ircd.cc b/ircd/ircd.cc index 31bc36d6f..482383df4 100644 --- a/ircd/ircd.cc +++ b/ircd/ircd.cc @@ -107,26 +107,6 @@ ircd::maintenance } }; -/// Coarse mode indicator for degraded operation known as "write-avoid" which -/// is similar to read_only but not hard-enforced. Writes may still occur, -/// such as those manually triggered by an admin. All subsystems and background -/// tasks otherwise depart from normal operation to avoid writes. -decltype(ircd::write_avoid) -ircd::write_avoid -{ - { - { "name", "ircd.write_avoid" }, - { "default", false }, - { "persist", false }, - }, - [](conf::item &) - { - if(!write_avoid) - return; - - maintenance.set("true"); - } -}; /// Coarse mode declaration for read-only behavior. All subsystems and feature /// modules respect this indicator by preventing any writes and persistence @@ -145,7 +125,7 @@ ircd::read_only if(!read_only) return; - write_avoid.set("true"); + maintenance.set("true"); } }; diff --git a/ircd/logger.cc b/ircd/logger.cc index de84386eb..78065c485 100644 --- a/ircd/logger.cc +++ b/ircd/logger.cc @@ -138,7 +138,7 @@ ircd::log::init() console_disable(level::DWARNING); } - if(!ircd::write_avoid) + if(!ircd::read_only && !ircd::maintenance) { mkdir(); open(); diff --git a/matrix/app.cc b/matrix/app.cc index 10f36c00f..b69fe0fdb 100644 --- a/matrix/app.cc +++ b/matrix/app.cc @@ -354,7 +354,7 @@ ircd::m::app::handle_stdout() const auto message_id { - !ircd::write_avoid? + !ircd::read_only && !ircd::maintenance? m::msghtml(room_id, user_id, content, string_view{alt}, "m.notice"): m::event::id::buf{} }; diff --git a/matrix/homeserver.cc b/matrix/homeserver.cc index 7262ba192..f8df465c9 100644 --- a/matrix/homeserver.cc +++ b/matrix/homeserver.cc @@ -283,17 +283,17 @@ try if(ircd::mods::autoload) mods::imports.emplace("net_dns_cache"s, "net_dns_cache"); - if(!ircd::write_avoid) + if(!ircd::read_only && !ircd::maintenance) if(key && !key->verify_keys.empty()) m::keys::cache::set(key->verify_keys); if(opts->autoapps) m::app::init(); - if(!ircd::maintenance) + if(!ircd::read_only && !ircd::maintenance) signon(*this); - if(!ircd::maintenance && opts->backfill) + if(!ircd::read_only && !ircd::maintenance && opts->backfill) m::init::backfill::init(); } catch(const std::exception &e) @@ -321,7 +321,7 @@ noexcept try server::wait(); m::sync::pool.join(); - if(!ircd::maintenance && _vm) + if(!ircd::read_only && !ircd::maintenance && _vm) signoff(*this); ///TODO: XXX primary @@ -394,7 +394,7 @@ ircd::m::homeserver::key::key(const struct opts &opts) }) }; - if(!fs::exists(sk_file) && !ircd::write_avoid) + if(!fs::exists(sk_file) && !ircd::read_only && !ircd::maintenance) log::notice { m::log, "Creating ed25519 secret key @ `%s'", sk_file @@ -404,7 +404,7 @@ ircd::m::homeserver::key::key(const struct opts &opts) }()} ,secret_key { - secret_key_path, &public_key, !ircd::write_avoid + secret_key_path, &public_key, !ircd::read_only && !ircd::maintenance } ,public_key_b64 { diff --git a/modules/m_bridge.cc b/modules/m_bridge.cc index 0b95f702a..c631b707d 100644 --- a/modules/m_bridge.cc +++ b/modules/m_bridge.cc @@ -52,8 +52,8 @@ IRCD_MODULE decltype(ircd::m::bridge::enable) ircd::m::bridge::enable { - { "name", "ircd.m.bridge.enable" }, - { "default", true }, + { "name", "ircd.m.bridge.enable" }, + { "default", true && !ircd::maintenance }, }; decltype(ircd::m::bridge::backoff) @@ -139,7 +139,7 @@ ircd::m::bridge::init() string_view{event.event_id}, }; - if(!enable) + if(!enable || ircd::read_only) return true; start(event, config); @@ -169,7 +169,7 @@ ircd::m::bridge::handle_config(const m::event &event, vm::eval &eval) try { - if(!enable) + if(!enable || ircd::read_only) return; const config config