Shutdown command

This commit is contained in:
2025-12-21 15:09:44 +01:00
parent c45f9a59ca
commit 8aa3fe17c1
7 changed files with 66 additions and 9 deletions
+9 -1
View File
@@ -4,7 +4,8 @@ pub mod types;
use std::{
io::{BufRead, BufReader, Write},
net::TcpStream,
sync::Arc,
process::Child,
sync::{Arc, Mutex},
};
use crate::{
@@ -17,6 +18,7 @@ pub struct Plugin {
stream: TcpStream,
reader: BufReader<TcpStream>,
id: String,
child: Arc<Mutex<Child>>,
}
impl Plugin {
@@ -60,4 +62,10 @@ impl Plugin {
}
}
}
pub fn stop(&mut self) {
self.send(&LoaderMessage::Shutdown).unwrap();
self.stream.shutdown(std::net::Shutdown::Both).unwrap();
self.child.lock().unwrap().kill().unwrap();
}
}