question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NestFactory.createApplicationContext run successfully but never exit. How to shutdown app gracefully?

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
smonvcommented, Mar 12, 2019

I’m using NestJS version 5.7.3 but still get this issue. Any update ?

0reactions
lock[bot]commented, Sep 24, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found