Initial commit.

Signed-off-by: Edu4rdSHL <edu4rdshl@protonmail.com>
This commit is contained in:
Edu4rdSHL 2021-06-09 19:48:31 -05:00
parent 23f888270e
commit f711691e11
No known key found for this signature in database
GPG key ID: 3A574A4009F553E5
2 changed files with 26 additions and 19 deletions

View file

@ -1,2 +1,2 @@
file1.txt:8080 file1.txt:8080
file2.txt:9090 file2.txt:8090

View file

@ -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<()>>();
} }