Skip to content

Commit

Permalink
stop managed mjolnirs
Browse files Browse the repository at this point in the history
  • Loading branch information
H-Shay committed Oct 21, 2024
1 parent fac9f2d commit c7aad5c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/appservice/AppService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ export class MjolnirAppService {
await this.dataStore.close();
await this.api.close();
this.openMetrics.stop();
this.mjolnirManager.closeAll();
}

/**
Expand Down
16 changes: 16 additions & 0 deletions src/appservice/MjolnirManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<string> {
return await this.mjolnir.client.getUserId();
}
Expand Down

0 comments on commit c7aad5c

Please sign in to comment.