NestFactory.createApplicationContext run successfully but never exit. How to shutdown app gracefully?
See original GitHub issueI love this idea so much, Thanks to that, you can take advantages of the Nest framework everywhere, including CRON jobs and even build a CLI on top of it.
, but stuck.
create app context and invoke marketService.test()
import { NestFactory } from "@nestjs/core";
import { ApplicationModule } from "../../src/app.module";
import { TradeModule } from "../../src/trade/trade.module";
import { MarketService } from "../../src/trade/services";
const run = async () => {
const app = await NestFactory.createApplicationContext(ApplicationModule);
const marketService: MarketService = app.select(TradeModule).get(MarketService);
marketService.test();
}
run();
marketService.test() log message successfully, but script never exit. how can I use i in CRON?
4:38 $ ts-node script/app/context.ts
[Nest] 68465 - 2018/3/13 下午2:38:21 [NestFactory] Starting Nest application...
(node:68465) Warning: N-API is an experimental feature and could change at any time.
[Nest] 68465 - 2018/3/13 下午2:38:22 [InstanceLoader] ApplicationModule dependencies initialized +29ms
[Nest] 68465 - 2018/3/13 下午2:38:22 [InstanceLoader] MongooseModule dependencies initialized +1ms
[Nest] 68465 - 2018/3/13 下午2:38:22 [InstanceLoader] MongooseCoreModule dependencies initialized +91ms
[Nest] 68465 - 2018/3/13 下午2:38:22 [InstanceLoader] AppConfigModule dependencies initialized +1ms
[Nest] 68465 - 2018/3/13 下午2:38:22 [InstanceLoader] TradeModule dependencies initialized +23ms
[Nest] 68465 - 2018/3/13 下午2:38:22 [InstanceLoader] MongooseModule dependencies initialized +2ms
MarketService test
<----- !!!stop here, never exit!!!
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
NestFactory.createApplicationContext run successfully but ...
NestFactory.createApplicationContext run successfully but never exit. How to shutdown app gracefully?
Read more >Standalone applications - A progressive Node.js framework
Nest is a framework for building efficient, scalable Node.js server-side applications. It uses progressive JavaScript, is built with TypeScript and combines ...
Read more >Nest: Cannot create a new connection named "default ...
createApplicationContext (MailModule); // we close the redundant connection before we mount the app. await getConnection('default').close(); ...
Read more >Injectable Pact.js Consumer/Producer for NestJS - Morioh
After creating the Nest application from the testing module, pass the app instance to the verify method, it will generate a random (available)...
Read more >The terminus from nestjs - Coder Social Home
index.ts with app = nestfactory.create() and app.listen,; app.module; ... I have studied graceful shutdown and I want to use terminus in my nest...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m using NestJS version
5.7.3
but still get this issue. Any update ?This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.