Getting error when trying to launch node.js app with PM2 Cluster
Asked Answered
C

3

8

in an Ubuntu Server, I am unable to run the node.js app in cluster mode using PM2.

The command I use is :

PM2 start server.js --name Server -i max

When I list the PM2 processes, I can see the Server has Error status. I have tried looking into the log file generated by PM2 but it's empty.

I am however able to run the same server.js without the cluster mode using :

PM2 start server.js --name Server

Commoner answered 12/7, 2018 at 8:17 Comment(0)
C
24

doing PM2 Kill and starting all the services again was the solution to above issue.

Commoner answered 12/7, 2018 at 10:52 Comment(0)
L
9

You could also have used pm2 restart Server to restart it

If you use pm2 kill you will just kill all processes, to clean up afterwards i would recommend to use pm2 flush so all logfiles will be reset

Lupine answered 12/7, 2018 at 13:32 Comment(1)
pm2 restart server didn't work in my situation. I used it several times before doing pm2 killCommoner
B
4

I have gone through this same kind of situations but in my case pm2 is showing error status cause of error in my code. use the below command

pm2 logs

pm2 logs command helped me by showing some hints to check where exactly the error is occured.

if everything works fine then pm2 list will show you the status online.

you can check the ports running by pm2(not only pm2 but all the process) using below command

sudo netstat -tulpn
Bullard answered 28/1, 2021 at 7:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.