more shit.
This commit is contained in:
1 parent
ba7763cbb1
commit
e7cec774d8
4 files changed
+112
-28
No files matched your search
+26
-4
@@ -1,3 +1,5 @@
|
||||
#![feature(future_join)]
|
||||
|
||||
mod views;
|
||||
mod config;
|
||||
|
||||
@@ -7,6 +9,10 @@ use minijinja_autoreload::AutoReloader;
|
||||
use std::io::{Error, ErrorKind};
|
||||
use std::path::Path;
|
||||
use std::{collections::HashMap, env, fs, io, path::PathBuf};
|
||||
use tokio::time::{sleep, Duration};
|
||||
use futures::{pin_mut, select, FutureExt};
|
||||
|
||||
|
||||
|
||||
use actix_web::{
|
||||
dev::ServiceResponse,
|
||||
@@ -55,6 +61,15 @@ impl FromRequest for MiniJinjaRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
async fn print_shit() -> std::io::Result<()>{
|
||||
let mut i = 0;
|
||||
loop {
|
||||
sleep(Duration::from_millis(1000)).await;
|
||||
println!("he he! {:?}", i);
|
||||
i +=1;
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
pub async fn web_ui_main(port: u16, enable_template_autoreload: bool) -> std::io::Result<()> {
|
||||
// The closure is invoked every time the environment is outdated to recreate it.
|
||||
@@ -74,7 +89,7 @@ pub async fn web_ui_main(port: u16, enable_template_autoreload: bool) -> std::io
|
||||
|
||||
let tmpl_reloader = web::Data::new(tmpl_reloader);
|
||||
|
||||
HttpServer::new(move || {
|
||||
let server = HttpServer::new(move || {
|
||||
App::new()
|
||||
.app_data(tmpl_reloader.clone())
|
||||
.service(views::index)
|
||||
@@ -86,9 +101,16 @@ pub async fn web_ui_main(port: u16, enable_template_autoreload: bool) -> std::io
|
||||
.wrap(Logger::default())
|
||||
})
|
||||
.workers(2)
|
||||
.bind(("0.0.0.0", port))?
|
||||
.run()
|
||||
.await
|
||||
.bind(("0.0.0.0", port))?;
|
||||
|
||||
let t1 = server.run().fuse();
|
||||
let t2 = print_shit().fuse();
|
||||
pin_mut!(t1, t2);
|
||||
|
||||
select!{
|
||||
x = t1 => x,
|
||||
y = t2 => y,
|
||||
}
|
||||
}
|
||||
|
||||
/// Error handler for a 404 Page not found error.
|
||||
|
||||
Reference in new issue
Block a user