Skip to content

Commit

Permalink
feat: add public files
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Aug 16, 2023
1 parent 009474a commit 800a29f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion counit-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,17 @@ pub mod agent;
async fn main() -> anyhow::Result<()> {
tracing_subscriber::fmt::init();

let config = Configuration::default();
// load configuration from public/config.json if exists
let config_file = std::path::Path::new("public/config.json");

let mut config: Configuration;
if config_file.exists() {
let config_string = std::fs::read_to_string(config_file)?;
config = serde_json::from_str(&config_string)?;
info!("Configuration loaded from public/config.json");
} else {
config = Configuration::default()
}

let bind = SocketAddr::new(config.host.parse()?, config.port);
let app = Application::initialize(config).await?;
Expand Down

0 comments on commit 800a29f

Please sign in to comment.