mirror of
https://github.com/edu4rdshl/webtail-rs.git
synced 2026-07-17 23:24:50 +00:00
Initial commit.
Signed-off-by: Edu4rdSHL <edu4rdshl@protonmail.com>
This commit is contained in:
parent
23f888270e
commit
f711691e11
2 changed files with 26 additions and 19 deletions
|
|
@ -1,2 +1,2 @@
|
||||||
file1.txt:8080
|
file1.txt:8080
|
||||||
file2.txt:9090
|
file2.txt:8090
|
||||||
|
|
|
||||||
43
src/main.rs
43
src/main.rs
|
|
@ -1,4 +1,4 @@
|
||||||
use std::{collections::HashMap, u16};
|
use std::{collections::HashMap, path::Path, u16};
|
||||||
|
|
||||||
use webtail_rs::{
|
use webtail_rs::{
|
||||||
structs::{File, State},
|
structs::{File, State},
|
||||||
|
|
@ -36,23 +36,30 @@ fn main() {
|
||||||
input_files
|
input_files
|
||||||
.par_iter()
|
.par_iter()
|
||||||
.map(|(file, port)| {
|
.map(|(file, port)| {
|
||||||
println!("=> Watching file {} in port {}\n", file, port);
|
if Path::new(&file).exists() {
|
||||||
let error = rocket::custom(
|
println!("=> Watching file {} in port {}\n", file, port);
|
||||||
Config::build(Environment::Production)
|
let error = rocket::custom(
|
||||||
.log_level(LoggingLevel::Off)
|
Config::build(Environment::Production)
|
||||||
.port(port.to_owned())
|
.log_level(LoggingLevel::Off)
|
||||||
.unwrap(),
|
.port(port.to_owned())
|
||||||
)
|
.unwrap(),
|
||||||
.manage(File {
|
)
|
||||||
data: String::new(),
|
.manage(File {
|
||||||
name: file.clone(),
|
data: String::new(),
|
||||||
state: State::Write,
|
name: file.clone(),
|
||||||
delay: args.delay,
|
state: State::Write,
|
||||||
})
|
delay: args.delay,
|
||||||
.mount("/", routes![updates])
|
})
|
||||||
.mount("/", StaticFiles::from("static"))
|
.mount("/", routes![updates])
|
||||||
.launch();
|
.mount("/", StaticFiles::from("static"))
|
||||||
eprintln!("Launch failed! Error: {}", error);
|
.launch();
|
||||||
|
eprintln!(
|
||||||
|
"Launch failed for file {} in port {}! Error: {}",
|
||||||
|
file, port, error
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
eprintln!("Ignoring file {} because doesn't exists.", file)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.collect::<Vec<()>>();
|
.collect::<Vec<()>>();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue