mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-09-12 18:44:25 +08:00
fix:修复在线升级错误
This commit is contained in:
16
src/state.rs
16
src/state.rs
@@ -1,4 +1,4 @@
|
||||
use std::{collections::VecDeque, sync::Arc};
|
||||
use std::{collections::VecDeque, path::PathBuf, sync::Arc};
|
||||
use tokio::sync::{broadcast, watch, Mutex, RwLock};
|
||||
|
||||
use crate::atx::AtxController;
|
||||
@@ -33,6 +33,12 @@ pub struct ConfigApplyLocks {
|
||||
pub rtsp: Arc<Mutex<()>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum ShutdownAction {
|
||||
Exit,
|
||||
Restart { exe_path: Option<PathBuf> },
|
||||
}
|
||||
|
||||
impl ConfigApplyLocks {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
@@ -68,7 +74,7 @@ pub struct AppState {
|
||||
pub events: Arc<EventBus>,
|
||||
device_info_tx: watch::Sender<Option<SystemEvent>>,
|
||||
pub update: Arc<UpdateService>,
|
||||
pub shutdown_tx: broadcast::Sender<()>,
|
||||
pub shutdown_tx: broadcast::Sender<ShutdownAction>,
|
||||
pub revoked_sessions: Arc<RwLock<VecDeque<String>>>,
|
||||
pub config_apply_locks: ConfigApplyLocks,
|
||||
data_dir: std::path::PathBuf,
|
||||
@@ -93,7 +99,7 @@ impl AppState {
|
||||
extensions: Arc<ExtensionManager>,
|
||||
events: Arc<EventBus>,
|
||||
update: Arc<UpdateService>,
|
||||
shutdown_tx: broadcast::Sender<()>,
|
||||
shutdown_tx: broadcast::Sender<ShutdownAction>,
|
||||
data_dir: std::path::PathBuf,
|
||||
) -> Arc<Self> {
|
||||
let (device_info_tx, _device_info_rx) = watch::channel(None);
|
||||
@@ -129,10 +135,6 @@ impl AppState {
|
||||
&self.data_dir
|
||||
}
|
||||
|
||||
pub fn shutdown_signal(&self) -> broadcast::Receiver<()> {
|
||||
self.shutdown_tx.subscribe()
|
||||
}
|
||||
|
||||
pub fn subscribe_device_info(&self) -> watch::Receiver<Option<SystemEvent>> {
|
||||
self.device_info_tx.subscribe()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user