Every time when I start a pm2 server. I can detect a constant data flow (40kb/s) to rev.poneytelecom.eu. Is this supposed to be normal behavior?
The connection to rev.poneytelecom.eu is due to the pm2 Keymetrics link connection that is enabled.
To disable the connection run:
pm2 link delete
Related
I made a gRPC client in node and i start it through pm2 with a simple:
pm2 start --name myAppName
The gRPC client have some listener on.data, on.error on.end etc
All works well but sometimes the gRPC server trigger the on.end with an error and then the script stop.
Error: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error)
I was expecting that by default pm2 job was to restart in that case but it seem not.
Do i needs to explicitely use a restart strategy like "--exp-backoff-restart-delay=100" when i start the app with pm2 for it to restart automatically in that situation? --watch option is not related here right? its only for file change restart is that correct?
Thanks in advance for the help.
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
doing PM2 Kill and starting all the services again was the solution to above issue.
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
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
I have a node chat application that needs to keep running on my server (ubuntu with nginx). The problem is that the application stops after a few hours or days.
When I check on the server I see that my pm2 list is empty.
The code I use to start my app:
pm2 start notification_server/index.js
It somehow looks as if pm2 is reset after a while. I also tried using forever, but then I run into the same problem. Is there some way to prevent the pm2 list from getting empty?
This is most likely an indication that your server is rebooting. When your server reboots, PM2 shuts down and deletes all Node instances from its "status" list.
You can perform the following steps to make PM2 relaunch your Node programs start back up on reboot:
Run pm2 startup and follow the directions (you will have to perform a sudo command; PM will tell you exactly what to do).
Through pm2 start, get your Node processes up and running just like you like them.
Run pm2 save to register the current state of things as what you want to see on system startup.
Source: http://pm2.keymetrics.io/docs/usage/startup/
Did you try checking logs $ pm2 logs for you application?
Most likely it will tell you why your application was terminated or maybe it just exited as it supposed to. You could find something like that there:
PM2 | App [app] with id [0] and pid [11982], exited with code [1] via signal [SIGINT]
This can tell you what happened. Without more details, it's hard to give you a better answer.
Currently, I have a NodeJS service running on my server. It provides a RestAPI thanks to HAPI.JS
This service run permanently with forever executed in upstart script but I got some trouble.
Sometimes, the service have an error like this :
Debug: internal, implementation, error
TypeError: Uncaught error: Cannot call method 'replace' of undefined....
At this moment, server is completly down and never restart :(
I need a 100% stable service that why I have to restart it when an error appears.
My Question :
How can I restart NodeJS Service with forever when errors occured ?
Run you app with pm2 instead of forever. Pm2 will restart the node server even after uncaught exceptions.
If the process fails on startup then it won't restart automatically. You can configure the minimum uptime --minUptime flag.
You can then use the --watch flag to watch for changes of the fix.
However, the specific error you're receiving wouldn't normally stop the Hapi process which would suggest this isn't a forever issue.
I have a Node.js app ready which is workable, but has known and unknown bugs which crash the app. In such cases it would be nice if pm2 can restart the node app. Is this feature already available in pm2?
Yes, it does this by default. For more information see Restart strategies.
If the app repeatedly fails to start over a short period of time, pm2 may cease restarting. See configuration, min_uptime and max_restarts.
Also, check this new excellent option:
--exp-backoff-restart-delay=100
pm2 will restart the crashed app after 100 milliseconds (0.1 seconds), then step-by-step increase restart-delay to 15 seconds.
To make app restart when it crashes you have to use one of PM2's restart strategies.
There is something called "Exponential Backoff Restart Delay" which PM2 explains as:
Instead of restarting your application like crazy when exceptions happens (e.g. database is down), the exponential backoff restart will increase incrementaly the time between restarts.
You can set it using the CLI like this:
pm2 start app.js --exp-backoff-restart-delay=100
There are other restart methods also, which are mentioned here.
This may help:
# Generate Startup Script
$ pm2 startup
# Freeze your process list across server restart
$ pm2 save
# Remove Startup Script
$ pm2 unstartup
More details here