mirror of
https://github.com/nicotsx/zerobyte.git
synced 2026-04-17 21:37:06 -04:00
36 lines
786 B
TypeScript
36 lines
786 B
TypeScript
import { runDbMigrations } from "../../db/db";
|
|
import { agentManager, spawnLocalAgent, stopAgentRuntime } from "../agents/agents-manager";
|
|
import { runMigrations } from "./migrations";
|
|
import { startup } from "./startup";
|
|
|
|
let bootstrapPromise: Promise<void> | undefined;
|
|
|
|
const runBootstrap = async () => {
|
|
await runDbMigrations();
|
|
await runMigrations();
|
|
agentManager.start();
|
|
await spawnLocalAgent();
|
|
await startup();
|
|
};
|
|
|
|
export const bootstrapApplication = async () => {
|
|
if (!bootstrapPromise) {
|
|
bootstrapPromise = runBootstrap();
|
|
}
|
|
|
|
try {
|
|
await bootstrapPromise;
|
|
} catch (err) {
|
|
bootstrapPromise = undefined;
|
|
throw err;
|
|
}
|
|
};
|
|
|
|
export const stopApplicationRuntime = async () => {
|
|
try {
|
|
await stopAgentRuntime();
|
|
} finally {
|
|
bootstrapPromise = undefined;
|
|
}
|
|
};
|