Search code examples
nestjspm2

Hangs on build using nestjs, pm2


I want to provide uninterrupted service using nestjs, pm2.

I download the changes via git pull origin master command. After that, save the new changes through the yarn build command. At this time, the service stops with an error saying dist/main.js cannot be found.

I tried to move the dist folder that was build outside the operating folder using mv, but it stopped and the service started again after entering the reload command.

Below is my code. How can I operate uninterrupted service?

//ecosystem.config.js
name: 'my_api',
      script: 'dist/main.js',
      watch: '.',
      instances: 2,
      exec_mode: 'cluster',
      wait_ready: true,
      listen_timeout: 20000,
      kill_timeout: 5000


//package.json
"prebuild": "rimraf dist",
"start": "yarn build && pm2 start ecosystem.config.js",

Solution

  • I removed the watch:'.', the service did not stop during build, and I was able to run it normally through the command pm2 reload myApp.