Răsfoiți Sursa

chore: Start job queue in population tasks

Michael Bromley 4 ani în urmă
părinte
comite
c8b2537817

+ 3 - 2
packages/create/src/create-vendure-app.ts

@@ -203,7 +203,7 @@ async function createApp(
                     const { populate } = await import(
                         path.join(root, 'node_modules/@vendure/core/cli/populate')
                     );
-                    const { bootstrap, DefaultLogger, LogLevel } = await import(
+                    const { bootstrap, DefaultLogger, LogLevel, JobQueueService } = await import(
                         path.join(root, 'node_modules/@vendure/core/dist/index')
                     );
                     const { config } = await import(ctx.configFile);
@@ -219,7 +219,7 @@ async function createApp(
                             : LogLevel.Info;
                     const bootstrapFn = async () => {
                         await checkDbConnection(config.dbConnectionOptions, root);
-                        return bootstrap({
+                        const _app = await bootstrap({
                             ...config,
                             apiOptions: {
                                 ...(config.apiOptions ?? {}),
@@ -238,6 +238,7 @@ async function createApp(
                                 importAssetsDir: path.join(assetsDir, 'images'),
                             },
                         });
+                        _app.get(JobQueueService).start();
                     };
                     let app: any;
                     if (populateProducts) {

+ 6 - 2
packages/dev-server/populate-dev-server.ts

@@ -1,6 +1,6 @@
 // tslint:disable-next-line:no-reference
 /// <reference path="../core/typings.d.ts" />
-import { bootstrap, defaultConfig, mergeConfig } from '@vendure/core';
+import { bootstrap, defaultConfig, JobQueueService, mergeConfig } from '@vendure/core';
 import { populate } from '@vendure/core/cli';
 import { clearAllTables, populateCustomers } from '@vendure/testing';
 import path from 'path';
@@ -32,7 +32,11 @@ if (require.main === module) {
     clearAllTables(populateConfig, true)
         .then(() =>
             populate(
-                () => bootstrap(populateConfig),
+                () =>
+                    bootstrap(populateConfig).then(async app => {
+                        await app.get(JobQueueService).start();
+                        return app;
+                    }),
                 initialData,
                 path.join(__dirname, '../create/assets/products.csv'),
             ),