Nareshkumar Rao 7 months ago
parent
commit
5819fcc7f9
  1. 1
      growpi.service
  2. 13
      src/main.rs

1
growpi.service

@ -7,6 +7,7 @@ Type=simple
Restart=always
RestartSec=10
ExecStart=/opt/growpi/growpi
WorkingDirectory=/opt/growpi
[Install]
WantedBy=mutli-user.target

13
src/main.rs

@ -19,11 +19,16 @@ mod state;
fn load_config() -> config::Configuration {
let config = Configuration::from_file(std::path::Path::new("./growpi.toml"));
if let Err(config) = &config {
println!("Could not load config: {}", config);
match config {
Ok(config) => config,
Err(_) => {
let config = Configuration::default();
config
.save_to_file(std::path::Path::new("./growpi.toml"))
.expect("Could not create default config in ./growpi.toml");
config
}
}
config.unwrap_or_default()
}
#[tokio::main(flavor = "current_thread")]

Loading…
Cancel
Save