1

I created folder for project, copy package.json and run npm install, build locally nestjs project and copy dist into server. Then ran in console node dist/main.js. For testing I used a base NestJS project (nest new ...) which only return "Hello word" on 3000 port.

Server work fine, but after close of console will stop.

I think problem on VPS (Ubuntu) settings or may be need to add some parameters to NestJS.

Why it not work constantly?

Thanks in advance for any advice.

jww
  • 97,681
  • 90
  • 411
  • 885
V.Tur
  • 1,115
  • 9
  • 20
  • 2
    Possible duplicate of [How do I run a node.js app as a background service?](https://stackoverflow.com/questions/4018154/how-do-i-run-a-node-js-app-as-a-background-service) – Kim Kern Nov 28 '19 at 14:51
  • O! Seems this may resolve my issue. I'll try implement it in closest days and write result. – V.Tur Nov 28 '19 at 15:18

1 Answers1

2

I resolved problem with npm forever - https://www.npmjs.com/package/forever install it globally - npm install forever -g then got to project dir and run - forever start dist/main.js Seems all work fine.

V.Tur
  • 1,115
  • 9
  • 20
  • what If I need to run with --watch? – Harsh Makwana Feb 06 '22 at 07:27
  • I'm not sure that you can run --watch with forever. When I need use dev mode I write npm run start:dev and not close console. By the way last time I prefer use pm2 instead forever https://www.npmjs.com/package/pm2 – V.Tur Feb 07 '22 at 07:22