Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions src/appservice/AppService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,22 @@ export class MjolnirAppService {
): Promise<MjolnirAppService> {
Logger.configure(config.logging ?? { console: "debug" });
const dataStore = new PgDataStore(config.db.connectionString);
await dataStore.init();
const service = await MjolnirAppService.makeMjolnirAppService(
config,
dataStore,
DefaultEventDecoder,
registrationFilePath
);
// The call to `start` MUST happen last. As it needs the datastore, and the mjolnir manager to be initialized before it can process events from the homeserver.
await service.start(port);
return service;
try {
await dataStore.init();
const service = await MjolnirAppService.makeMjolnirAppService(
config,
dataStore,
DefaultEventDecoder,
registrationFilePath
);
// The call to `start` MUST happen last. As it needs the datastore, and the mjolnir manager to be initialized before it can process events from the homeserver.
await service.start(port);
return service;
} catch (e: unknown) {
log.error("Failed to start the appservice", e);
await dataStore.close();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is still kinda shit

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like it, there's a close method on the MjolnirAppService that we hsould be calling somewhere but we don't ever

throw e;
}
}

public onUserQuery(_queriedUser: MatrixUser) {
Expand Down
11 changes: 1 addition & 10 deletions src/appservice/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import { Cli } from "matrix-appservice-bridge";
import { MjolnirAppService } from "./AppService";
import { IConfig } from "./config/config";
import { Task } from "matrix-protection-suite";

/**
* This file provides the entrypoint for the appservice mode for draupnir.
Expand All @@ -31,15 +30,7 @@ const cli = new Cli({
if (config === null) {
throw new Error("Couldn't load config");
}
void Task(
(async () => {
await MjolnirAppService.run(
port,
config,
cli.getRegistrationFilePath()
);
})()
);
void MjolnirAppService.run(port, config, cli.getRegistrationFilePath());
},
});

Expand Down
Loading