mirror of
https://github.com/the-draupnir-project/Draupnir.git
synced 2026-08-28 13:24:04 +00:00
Stop hanging if appservice crashes at startup.
Fixes https://github.com/the-draupnir-project/Draupnir/issues/503.
This commit is contained in:
@@ -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();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public onUserQuery(_queriedUser: MatrixUser) {
|
||||
|
||||
+1
-10
@@ -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.
|
||||
@@ -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());
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user