Skip to content

Commit

Permalink
Merge pull request #28 from perpetualcacophony/release/v1.8.4
Browse files Browse the repository at this point in the history
hotfix to allow changing the config file location
  • Loading branch information
perpetualcacophony authored Aug 18, 2024
2 parents 6cf0d54 + 7fb5233 commit da6a7fe
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ kwordle = { git = "https://github.com/perpetualcacophony/kwordle", branch = "mas
"classic_words",
"step",
], optional = true, version = "0.5.5" }
dotenvy = "0.15.7"

[dev-dependencies]
pretty_assertions = "1.4.0"
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ RUN cargo +nightly build --release --target x86_64-unknown-linux-musl
FROM alpine AS runtime
COPY --link --from=builder /app/target/x86_64-unknown-linux-musl/release/slimebot /usr/local/bin/slimebot
EXPOSE 443
USER slimebot:slimebot
ENTRYPOINT ["slimebot"]
15 changes: 12 additions & 3 deletions src/framework/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::commands::wordle::core::WordleData;
use mongodb::Database;

use chrono::Utc;
use tracing::trace;
use tracing::{info, trace, warn};
use tracing_unwrap::ResultExt;

pub(crate) type UtcDateTime = chrono::DateTime<Utc>;
Expand All @@ -27,9 +27,18 @@ pub struct PoiseData {

impl PoiseData {
pub(crate) fn new() -> Self {
dotenvy::dotenv().ok();

let config_file = if let Ok(path) = std::env::var("SLIMEBOT_TOML") {
info!(path, "looking for config file with SLIMEBOT_TOML...");
path
} else {
warn!("SLIMEBOT_TOML env unset, using default path /usr/share/slimebot/slimebot.toml");
"/usr/share/slimebot/slimebot.toml".to_owned()
};

let config: super::config::Config = ::config::Config::builder()
.add_source(::config::File::with_name("slimebot.toml"))
.add_source(::config::Environment::with_prefix("SLIMEBOT"))
.add_source(::config::File::with_name(&config_file))
.build()
.expect_or_log("config file could not be loaded")
.try_deserialize()
Expand Down

0 comments on commit da6a7fe

Please sign in to comment.