mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-26 11:21:30 +01:00
Use process group for node runtime
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
extern crate core;
|
||||
|
||||
use tauri::plugin::{Builder, TauriPlugin};
|
||||
use tauri::{Manager, Runtime};
|
||||
|
||||
use log::info;
|
||||
use crate::manager::PluginManager;
|
||||
use tauri::plugin::{Builder, TauriPlugin};
|
||||
use tauri::{Manager, RunEvent, Runtime, State};
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
pub mod manager;
|
||||
mod nodejs;
|
||||
@@ -17,9 +18,20 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
.setup(|app, _| {
|
||||
tauri::async_runtime::block_on(async move {
|
||||
let manager = PluginManager::new(&app).await;
|
||||
app.manage(manager);
|
||||
let manager_state = Mutex::new(manager);
|
||||
app.manage(manager_state);
|
||||
Ok(())
|
||||
})
|
||||
})
|
||||
.on_event(|app, e| match e {
|
||||
RunEvent::ExitRequested { code, .. } => {
|
||||
tauri::async_runtime::block_on(async move {
|
||||
info!("Exiting plugin runtime because of app exit {:?}", code);
|
||||
let manager: State<Mutex<PluginManager>> = app.state();
|
||||
manager.lock().await.cleanup();
|
||||
});
|
||||
}
|
||||
_ => {}
|
||||
})
|
||||
.build()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user