dashboard(cli): autoload enabled plugins before route mount
The plugin route mount in createApiRoutes runs once at server start, iterating pluginLoader.getPluginRoutes() to bind handlers and to register their paths as daemon-auth exempt. Without an autoload step the loader is empty at mount time, so plugin routes are missing until the next restart even after a successful enable through the dashboard API — Express routes can't be added after listen(). Add a pluginLoader.loadAllPlugins() call before createServer to mirror what runtime-providing plugins (paperclip etc.) already assume: enabled plugins are live the moment fusion starts. Failure of an individual plugin's load doesn't fail startup.
This commit is contained in:
@@ -1385,6 +1385,28 @@ export async function runDashboard(port: number, opts: { paused?: boolean; dev?:
|
||||
await closeCentralCoreBestEffort(centralCoreForEngine, "dispose cleanup");
|
||||
});
|
||||
|
||||
// Autoload all enabled plugins before mounting routes. createApiRoutes
|
||||
// iterates pluginLoader.getPluginRoutes() ONCE at server start to mount
|
||||
// plugin-defined HTTP handlers (and to register their paths as exempt
|
||||
// from daemon auth). Without this autoload step the loader is empty at
|
||||
// mount time, so no plugin route exists at startup; enabling a plugin
|
||||
// later via the dashboard API loads it into memory but Express routes
|
||||
// can't be added after listen(). Loading them up-front is the cheap
|
||||
// path that mirrors how runtime-providing plugins (paperclip etc.)
|
||||
// expect to be available immediately.
|
||||
try {
|
||||
const result = await pluginLoader.loadAllPlugins();
|
||||
logSink.log(
|
||||
`Autoloaded ${result.loaded} plugin(s), ${result.errors} error(s)`,
|
||||
"plugin-loader",
|
||||
);
|
||||
} catch (err) {
|
||||
logSink.warn(
|
||||
`Plugin autoload failed: ${err instanceof Error ? err.message : String(err)}`,
|
||||
"plugin-loader",
|
||||
);
|
||||
}
|
||||
|
||||
app = createServer(store, {
|
||||
engine: cwdEngine,
|
||||
engineManager,
|
||||
|
||||
Reference in New Issue
Block a user