add commandline arg to specify a conduwuit config file

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-03-09 18:41:26 -05:00 committed by June
parent aec7097cd3
commit d52f03414e
2 changed files with 20 additions and 4 deletions

View file

@ -79,4 +79,5 @@
- Make `CONDUIT_CONFIG` optional, relevant for container users that configure only by environment variables and no longer need to set `CONDUIT_CONFIG` to an empty string.
- Config option to change Conduit's behaviour of homeserver key fetching (`query_trusted_key_servers_first`). This option sets whether conduwuit will query trusted notary key servers first before the individual homeserver(s), or vice versa.
- Implement database flush and cleanup Conduit operations when using RocksDB
- Implement legacy Matrix `/v1/` media endpoints that some clients and servers may still call
- Implement legacy Matrix `/v1/` media endpoints that some clients and servers may still call
- Commandline argument to specify the path to a config file

View file

@ -53,13 +53,18 @@ use tracing_subscriber::{prelude::*, EnvFilter};
#[global_allocator]
static GLOBAL: Jemalloc = Jemalloc;
#[derive(Parser)]
#[derive(Parser, Debug)]
#[clap(version, about, long_about = None)]
struct Args;
struct Args {
#[arg(short, long)]
/// Optional argument to the path of a conduwuit config TOML file
config: Option<String>,
}
#[tokio::main]
async fn main() {
Args::parse();
let args = Args::parse();
// Initialize config
let raw_config = if Env::var("CONDUIT_CONFIG").is_some() {
Figment::new()
@ -71,6 +76,16 @@ async fn main() {
.nested(),
)
.merge(Env::prefixed("CONDUIT_").global())
} else if args.config.is_some() {
Figment::new()
.merge(
Toml::file(args.config.expect(
"conduwuit config commandline argument was specified, but appears to be invalid. This should be \
set to the path of a valid TOML file.",
))
.nested(),
)
.merge(Env::prefixed("CONDUIT_").global())
} else {
Figment::new().merge(Env::prefixed("CONDUIT_").global())
};