mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-19 17:11:42 -06:00
perf(cli): attribute command startup stages (#117720)
This commit is contained in:
@@ -4,6 +4,7 @@ import type { RuntimeEnv } from "../runtime.js";
|
||||
import { createLazyImportLoader } from "../shared/lazy-promise.js";
|
||||
import type { CliPluginRegistryPolicy } from "./command-catalog.js";
|
||||
import { resolveCliCommandPathPolicy } from "./command-path-policy.js";
|
||||
import { measureCliCommandStartup } from "./command-startup-timing.js";
|
||||
import { ensureCliPluginRegistryLoaded } from "./plugin-registry-loader.js";
|
||||
|
||||
const configGuardModuleLoader = createLazyImportLoader(() => import("./program/config-guard.js"));
|
||||
@@ -26,19 +27,24 @@ export async function ensureCliCommandBootstrap(params: {
|
||||
skipPristineStartupStateMigrations?: boolean;
|
||||
}) {
|
||||
if (!params.skipConfigGuard) {
|
||||
const { ensureConfigReady } = await loadConfigGuardModule();
|
||||
await ensureConfigReady({
|
||||
runtime: params.runtime,
|
||||
commandPath: params.commandPath,
|
||||
...(params.allowInvalid ? { allowInvalid: true } : {}),
|
||||
...(params.beforeStateMigrations
|
||||
? { beforeStateMigrations: params.beforeStateMigrations }
|
||||
: {}),
|
||||
...(params.suppressDoctorStdout ? { suppressDoctorStdout: true } : {}),
|
||||
...(params.skipPristineStartupStateMigrations
|
||||
? { skipPristineStartupStateMigrations: true }
|
||||
: {}),
|
||||
...(params.skipPristineCoreStateMigrations ? { skipPristineCoreStateMigrations: true } : {}),
|
||||
await measureCliCommandStartup("config-ready", async () => {
|
||||
const { ensureConfigReady } = await loadConfigGuardModule();
|
||||
await ensureConfigReady({
|
||||
runtime: params.runtime,
|
||||
commandPath: params.commandPath,
|
||||
measure: (stage, run) => measureCliCommandStartup(stage, run),
|
||||
...(params.allowInvalid ? { allowInvalid: true } : {}),
|
||||
...(params.beforeStateMigrations
|
||||
? { beforeStateMigrations: params.beforeStateMigrations }
|
||||
: {}),
|
||||
...(params.suppressDoctorStdout ? { suppressDoctorStdout: true } : {}),
|
||||
...(params.skipPristineStartupStateMigrations
|
||||
? { skipPristineStartupStateMigrations: true }
|
||||
: {}),
|
||||
...(params.skipPristineCoreStateMigrations
|
||||
? { skipPristineCoreStateMigrations: true }
|
||||
: {}),
|
||||
});
|
||||
});
|
||||
}
|
||||
if (!params.loadPlugins) {
|
||||
@@ -46,8 +52,10 @@ export async function ensureCliCommandBootstrap(params: {
|
||||
}
|
||||
const pluginRegistryLoadPolicy =
|
||||
params.pluginRegistry ?? resolveCliCommandPathPolicy(params.commandPath).pluginRegistry;
|
||||
await ensureCliPluginRegistryLoaded({
|
||||
scope: pluginRegistryLoadPolicy.scope,
|
||||
routeLogsToStderr: params.suppressDoctorStdout,
|
||||
});
|
||||
await measureCliCommandStartup("plugin-registry", () =>
|
||||
ensureCliPluginRegistryLoaded({
|
||||
scope: pluginRegistryLoadPolicy.scope,
|
||||
routeLogsToStderr: params.suppressDoctorStdout,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user