rocket port
This commit is contained in:
parent
8b738777a8
commit
8b8049df2f
|
@ -15,6 +15,8 @@ mod server;
|
|||
struct Args {
|
||||
#[clap(long)]
|
||||
pairing_data: PathBuf,
|
||||
#[clap(long, default_value_t = 6666)]
|
||||
port: usize,
|
||||
}
|
||||
|
||||
const SENSORS: [ServiceType; 11] = [
|
||||
|
@ -36,7 +38,7 @@ async fn rocket() -> rocket::Rocket<rocket::Build> {
|
|||
env_logger::init();
|
||||
let args = Args::parse();
|
||||
match init(args.pairing_data).await {
|
||||
Ok(paired) => launch(paired),
|
||||
Ok(paired) => launch(paired, args.port),
|
||||
Err(e) => panic!("Error {e:#?}"),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,12 @@ use tokio::sync::Mutex;
|
|||
|
||||
use crate::SENSORS;
|
||||
|
||||
pub fn launch(paired: HashMap<String, DeviceConnection>) -> rocket::Rocket<rocket::Build> {
|
||||
pub fn launch(
|
||||
paired: HashMap<String, DeviceConnection>,
|
||||
port: usize,
|
||||
) -> rocket::Rocket<rocket::Build> {
|
||||
rocket::build()
|
||||
.configure(rocket::Config::figment().merge(("port", port)))
|
||||
.manage(Mutex::new(paired))
|
||||
.mount("/", routes![metrics])
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue