Skip to content

Commit

Permalink
fix: make build with new axum
Browse files Browse the repository at this point in the history
Signed-off-by: simonsan <[email protected]>
  • Loading branch information
simonsan committed Jan 1, 2024
1 parent 4478def commit 94b8b03
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ It allows to define client groups which are all backed up the same way.
- Copy the `rustic-scheduler-server` binary to your backup schedule server and
the `rustic-scheduler-client` binary to all your clients (available under
`/targets/release`).
- Create a config file `rustic_schedulder.toml` on your backup schedule server
- Create a config file `./config/rustic_schedulder.toml` on your backup schedule server
(example config is available in the `config/` dir)
- Run the `rustic-scheduler-server` binary on your server in the dir containing
the config.
Expand Down
14 changes: 10 additions & 4 deletions src/bin/rustic-scheduler-server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::{collections::HashMap, fs::read_to_string, time::Duration};

use anyhow::Result;
use axum::{
extract::{
Expand All @@ -15,6 +14,7 @@ use log::warn;
use sailfish::TemplateOnce;
use tokio::{
spawn,
net::TcpListener,
sync::{mpsc, oneshot},
time::sleep,
};
Expand Down Expand Up @@ -47,7 +47,8 @@ enum NotifyMessage {

#[tokio::main]
async fn main() {
let config = read_to_string("rustic_scheduler.toml").unwrap();
// FIXME: Unhardcode config file and expose via CLI settings
let config = read_to_string("./config/rustic_scheduler.toml").unwrap();
let config: ConfigFile = toml::from_str(&config).unwrap();
config.validate().unwrap();

Expand Down Expand Up @@ -145,8 +146,13 @@ async fn main() {
.with_state(wtx);

// run it with hyper on localhost:3012
axum::Server::bind(&config.global.address.parse().unwrap())
.serve(app.into_make_service())
let listener = TcpListener::bind(&config.global.address)
.await
.unwrap();

println!("Listening on http://{}", config.global.address);

axum::serve(listener, app.into_make_service())
.await
.unwrap();
}
Expand Down

0 comments on commit 94b8b03

Please sign in to comment.