diff --git a/src/appservice/AppService.ts b/src/appservice/AppService.ts index 4c8f8c86..275d7c5f 100644 --- a/src/appservice/AppService.ts +++ b/src/appservice/AppService.ts @@ -208,6 +208,7 @@ export class MjolnirAppService { await this.dataStore.close(); await this.api.close(); this.openMetrics.stop(); + this.mjolnirManager.closeAll(); } /** diff --git a/src/appservice/MjolnirManager.ts b/src/appservice/MjolnirManager.ts index fd457d23..e0d4fe36 100644 --- a/src/appservice/MjolnirManager.ts +++ b/src/appservice/MjolnirManager.ts @@ -163,6 +163,15 @@ export class MjolnirManager { } } + /** + * Stop all the managed mjolnirs + */ + public closeAll() { + for (const mjolnir of this.perMjolnirId.values()) { + mjolnir.stop(); + } + } + /** * Utility that creates a matrix client for a virtual user on our homeserver with the specified loclapart. * @param localPart The localpart of the virtual user we need a client for. @@ -246,6 +255,13 @@ export class ManagedMjolnir { await this.mjolnir.start(); } + /** + * Stop Mjolnir from syncing and processing commands. + */ + public stop() { + this.mjolnir.stop(); + } + public async getUserId(): Promise { return await this.mjolnir.client.getUserId(); }