Skip to content

Commit

Permalink
fix(server): avoid sync imports during engine build when not necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
fcastill committed Jan 30, 2020
1 parent b2c5078 commit 3a677a4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions apps/server/src/configure-engines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ initDb({ autosave: false })
getInitializedEngine(config.defaultEngine.path, {
forceCreate: false,
useEngineConfig: true,
syncImportsOnCreation: true,
})
)
.then(engine => syncTasks(engine))
Expand Down
1 change: 1 addition & 0 deletions apps/server/src/init/bootstrap-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export async function boostrapEngine(enginePath: string) {
const engine = await getInitializedEngine(enginePath, {
forceCreate: !!process.env['FLOGO_WEB_ENGINE_FORCE_CREATION'],
useEngineConfig: true,
syncImportsOnCreation: true,
});
await engine.build();
await syncTasks(engine);
Expand Down
8 changes: 7 additions & 1 deletion apps/server/src/modules/engine/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export async function getInitializedEngine(
enginePath,
opts: {
forceCreate?: boolean;
syncImportsOnCreation?: boolean;
noLib?: boolean;
libVersion?: string;
useEngineConfig?: boolean;
Expand All @@ -46,7 +47,12 @@ export async function getInitializedEngine(
engineRegistry[enginePath] = engine;

const initTimer = logger.startTimer();
const engineExists = await engine.exists();
const isNewEngine = !engineExists || opts.forceCreate;
await initEngine(engine, opts);
if (isNewEngine && !opts.syncImportsOnCreation) {
engine.build({ syncImports: true });
}
initTimer.done('EngineInit');

return engine;
Expand Down Expand Up @@ -150,7 +156,7 @@ export function initEngine(engine, options) {
defaultFlogoDescriptorPath,
useContribBundle: !skipBundleInstall,
useEngineConfig,
}).then(() => engine.build({ syncImports: true }));
});
}
return true;
})
Expand Down

0 comments on commit 3a677a4

Please sign in to comment.