Shutdown command
This commit is contained in:
+9
-1
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user