Initial index on plug:run
This commit is contained in:
parent
2844c8bc25
commit
e23b0808e0
@ -26,7 +26,7 @@ export async function runPlug(
|
|||||||
dbPath,
|
dbPath,
|
||||||
app,
|
app,
|
||||||
);
|
);
|
||||||
await serverSystem.init();
|
await serverSystem.init(true);
|
||||||
app.listen({
|
app.listen({
|
||||||
hostname: httpHostname,
|
hostname: httpHostname,
|
||||||
port: httpServerPort,
|
port: httpServerPort,
|
||||||
|
@ -51,7 +51,7 @@ export class ServerSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Always needs to be invoked right after construction
|
// Always needs to be invoked right after construction
|
||||||
async init() {
|
async init(awaitIndex = false) {
|
||||||
// Event hook
|
// Event hook
|
||||||
const eventHook = new EventHook();
|
const eventHook = new EventHook();
|
||||||
this.system.addHook(eventHook);
|
this.system.addHook(eventHook);
|
||||||
@ -151,12 +151,15 @@ export class ServerSystem {
|
|||||||
// Check if this space was ever indexed before
|
// Check if this space was ever indexed before
|
||||||
if (!await this.ds.get(["$initialIndexDone"])) {
|
if (!await this.ds.get(["$initialIndexDone"])) {
|
||||||
console.log("Indexing space for the first time (in the background)");
|
console.log("Indexing space for the first time (in the background)");
|
||||||
this.system.loadedPlugs.get("index")!.invoke(
|
const indexPromise = this.system.loadedPlugs.get("index")!.invoke(
|
||||||
"reindexSpace",
|
"reindexSpace",
|
||||||
[],
|
[],
|
||||||
).then(() => {
|
).then(() => {
|
||||||
this.ds.set(["$initialIndexDone"], true);
|
this.ds.set(["$initialIndexDone"], true);
|
||||||
}).catch(console.error);
|
}).catch(console.error);
|
||||||
|
if (awaitIndex) {
|
||||||
|
await indexPromise;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await eventHook.dispatchEvent("system:ready");
|
await eventHook.dispatchEvent("system:ready");
|
||||||
|
Loading…
Reference in New Issue
Block a user