Added reload <plugin>
This commit is contained in:
+15
-1
@@ -122,7 +122,21 @@ pub fn start_cli(server: Arc<Server>, plugin_loader: PluginLoader) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
"load" "loads a plugin that has been installed" => {
|
"load" "loads a plugin that has been installed" => {
|
||||||
if require_args(&args, &["<plugin-dir>"]) {
|
if require_args(&args, &["<plugin-id>"]) {
|
||||||
|
plugin_loader.load(&server.root.join("plugins").join(&args[1]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"reload" "restarts a plugin that has been installed" => {
|
||||||
|
if require_args(&args, &["<plugin-id>"]) {
|
||||||
|
let target = args[1].as_str();
|
||||||
|
for plugin in server.plugins.lock().unwrap().iter_mut() {
|
||||||
|
if plugin.get_id() == target {
|
||||||
|
LOGGER.info("Stopping plugin");
|
||||||
|
if let Err(e) = plugin.stop() {
|
||||||
|
LOGGER.warn(e.context("Couldn't stop plugin"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
plugin_loader.load(&server.root.join("plugins").join(&args[1]));
|
plugin_loader.load(&server.root.join("plugins").join(&args[1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,4 +69,8 @@ impl Plugin {
|
|||||||
self.child.lock().unwrap().kill()?;
|
self.child.lock().unwrap().kill()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_id(&self) -> String {
|
||||||
|
self.id.clone()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user