worker.module.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { Module, OnApplicationShutdown } from '@nestjs/common';
  2. import { ConfigModule } from '../config/config.module';
  3. import { Logger } from '../config/logger/vendure-logger';
  4. import { ConnectionModule } from '../connection/connection.module';
  5. import { I18nModule } from '../i18n/i18n.module';
  6. import { PluginModule } from '../plugin/plugin.module';
  7. import { ProcessContextModule } from '../process-context/process-context.module';
  8. import { ServiceModule } from '../service/service.module';
  9. import { WorkerHealthService } from './worker-health.service';
  10. /**
  11. * This is the main module used when bootstrapping the worker process via
  12. * `bootstrapWorker()`. It contains the same imports as the AppModule except
  13. * for the ApiModule, which is not needed for the worker. Omitting the ApiModule
  14. * greatly increases startup time (about 4x in testing).
  15. */
  16. @Module({
  17. imports: [
  18. ProcessContextModule,
  19. ConfigModule,
  20. I18nModule,
  21. PluginModule.forRoot(),
  22. ConnectionModule.forRoot(),
  23. ServiceModule,
  24. ],
  25. providers: [WorkerHealthService],
  26. })
  27. export class WorkerModule implements OnApplicationShutdown {
  28. async onApplicationShutdown(signal?: string) {
  29. if (signal) {
  30. Logger.info('Received shutdown signal:' + signal);
  31. }
  32. }
  33. }