Restarting plugins
This commit is contained in:
parent
9841b7d571
commit
974fe320f0
17
src/cli.ts
17
src/cli.ts
@ -79,7 +79,7 @@ export class SqueebotCLI {
|
||||
}
|
||||
|
||||
private async pluginCommand(...args: any[]): Promise<void> {
|
||||
const help = 'plugin install | update | uninstall | enable | disable | start | stop | list | running [<name>]';
|
||||
const help = 'plugin install | update | uninstall | enable | disable | start | restart | stop | list | running [<name>]';
|
||||
if (!args[0] || args[0] === 'help' || (!args[1] && args[0] !== 'list' && args[0] !== 'running')) {
|
||||
logger.log(help);
|
||||
return;
|
||||
@ -126,8 +126,23 @@ export class SqueebotCLI {
|
||||
logger.log('Started plugin "%s" successfully.', name);
|
||||
}
|
||||
break;
|
||||
case 'restart':
|
||||
case 'reload':
|
||||
for (const name of args.slice(1)) {
|
||||
const plugin = this.bot.pluginManager.getAvailableByName(name);
|
||||
if (!plugin) {
|
||||
logger.error('"%s" is not available. Maybe try installing it? plugin install', name, name);
|
||||
return;
|
||||
}
|
||||
|
||||
logger.log('Scheduling restart for', name);
|
||||
|
||||
await this.bot.pluginManager.restart(plugin);
|
||||
}
|
||||
break;
|
||||
case 'stop':
|
||||
case 'kill':
|
||||
case 'unload':
|
||||
for (const name of args.slice(1)) {
|
||||
if (!this.bot.pluginManager.getAvailableByName(name)) {
|
||||
logger.error('No such plugin is available.');
|
||||
|
@ -76,6 +76,10 @@ export class Squeebot {
|
||||
// Start enabled plugins
|
||||
await this.startPlugins();
|
||||
}
|
||||
|
||||
// Send core on request
|
||||
this.stream.on('core', 'request-core', (pl: string) =>
|
||||
this.stream.emitTo(pl, 'core', this));
|
||||
}
|
||||
|
||||
public async startPlugins(): Promise<void> {
|
||||
|
Loading…
Reference in New Issue
Block a user