Going somewhere.
This commit is contained in:
1 parent
9f86d53d11
commit
0bbe716d8d
9 files changed
+160
-59
No files matched your search
+7
-5
@@ -18,7 +18,7 @@ use minijinja_autoreload::AutoReloader;
|
||||
use rusqlite::Connection;
|
||||
|
||||
use crate::events::Event;
|
||||
use crate::util::{CustomResult, Error};
|
||||
use crate::util::{CustomResult, Error, SQLiteConnectionFactory};
|
||||
use crate::webui::worker::{bob, event_processor_loop};
|
||||
|
||||
mod views;
|
||||
@@ -83,20 +83,22 @@ fn create_auto_reloader(enable_template_autoreload: bool) -> AutoReloader {
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
pub async fn web_ui_main(conn: &mut Connection,
|
||||
pub async fn web_ui_main(connFact: SQLiteConnectionFactory,
|
||||
port: u16,
|
||||
enable_template_autoreload: bool) -> CustomResult<()> {
|
||||
// The closure is invoked every time the environment is outdated to recreate it.
|
||||
let tmpl_reloader = create_auto_reloader(enable_template_autoreload);
|
||||
|
||||
let (s, r) = async_channel::unbounded::<Event>();
|
||||
let (event_sender, event_receiver) = async_channel::unbounded::<Event>();
|
||||
|
||||
let tmpl_reloader = web::Data::new(tmpl_reloader);
|
||||
|
||||
let clonedConnFact = connFact.clone();
|
||||
let server = HttpServer::new(move || {
|
||||
App::new()
|
||||
.app_data(tmpl_reloader.clone())
|
||||
.app_data(web::Data::new(s.clone()))
|
||||
.app_data(web::Data::new(event_sender.clone()))
|
||||
.app_data(web::Data::new(clonedConnFact.clone()))
|
||||
.service(
|
||||
actix_files::Files::new("/static", "./resources/static/").use_last_modified(true),
|
||||
)
|
||||
@@ -114,7 +116,7 @@ pub async fn web_ui_main(conn: &mut Connection,
|
||||
.unwrap();
|
||||
|
||||
let t1 = server.run().fuse();
|
||||
let t2 = event_processor_loop(conn, r).fuse();
|
||||
let t2 = event_processor_loop(connFact, event_receiver).fuse();
|
||||
let t3 = bob().fuse();
|
||||
pin_mut!(t1, t2, t3);
|
||||
|
||||
|
||||
Reference in new issue
Block a user