Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Kill process started with NPM (pm2)

I installed pm2 with NPM without the global flag. Then I started de index scrpit with "npm start" thath declared on package.json as

"start": "pm2 start index.js"

How con I stop it?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can access locally-installed pm2 with npx:

$ npx pm2 list
$ npx stop 0 # first app will have ID=0

But in general, I would manage it by attaching a name to the app. Let’s edit your package.json:

"start": "pm2 start index.js --name my-app"
"stop": "pm2 stop my-app",
"logs": "pm2 logs my-app"

And then:

$ npm run start
$ npm run logs
$ npm run stop
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading