PM2 can not reload application - node.js

My application is working very well. I`m using PM2 clustering mode in this application and I reloaded it to much without any error. But now when I wanna reload my app, it does not work and shows me this error :
This is my reloading command:
pm2 reload myapp

Related

Node app crashes after closing the terminal, even using pm2

I'm doing web automation by using Puppeteer with NodeJS. It works fine when I'm logged in to the terminal. I'm using ec2 instance Ubuntu 22 server.
But when I'm exit out of the terminal and then try to perform the task it just loads and loads and do nothing. But when I log in to check the pm2 logs then it starts working again with the terminal open.
When I check pm2 logs I get this error every time.
Error in pm2 logs:
I suppose there is problem with the command you are trying to run the app. Use the following command to run the app via pm2.
npx pm2 start app
For Cpanel Users having this issue
Login to your WHM account, click on the terminal, cd into the directory where your node js application is, then pm2 start .This was how i solved my issue.

Load node JS Web app so slow in VPS with pm2

Im using pm2 start app.js --watch but it's very slow to reload my web app. It always must to refresh the browser for get the page fast. What should i do?

NodeJS changes not reflected on server

I'm running NodeJS application on CentOS with PM2. Everything works fine.
But I made a query changes in one of the controller file (add new column in SQL query). And then uploaded the project files to server. And then run PM2 restart [app-id].
It's strange that new column was not returned in the api response payload.
Is there anyway to clear cache of PM2? or What is the issue exactly?
Please advise!
For me worked sudo -u nodejs pm2 restart hello
more info:
https://marketplace.digitalocean.com/apps/nodejs#getting-started
Try running the following command.
pm2 stop app_name
pm2 restart app_name
pm2 reload app_name

how to deploy expressjs application on window server

There many tools to deploy expressjs application, such as strongloop,pm2.
But they do not work well on windows.
I have install [pm2]2 in my window computer, and start my app.
https://i.stack.imgur.com/ZpOIa.jpg
But when i log off my computer and log in again. the service is disappear.
So I install pm2-windows-service and install pm2 as a window service. It failed again.
Anyone have a good expressjs deployment plan?
You need to make a pm2 save when you started your app. PM2 need to know which apps were started and their state to restart them after a reboot, and thats the aim of the pm2 save command which will save the state of all apps in the pm2 directory.

pm2 difference between stop and delete app

In pm2 node app manager, what is the difference between stop and delete app. I know that delete app deletes the app, from the pm2:s control, but what does stop app do? They both will set node server to offline.
My problem is that during deployment, if I want to pull code, and then restart the node server, then which pm2 commands to use? What I have done now is first pm2 stop app -> pull code -> pm2 start app. But how do I know that the app.js is really updated? What if stop puts the app in memory, and loads it there? So after start, it will start the previous version, and not from the code that was pulled.
Stop command keeps the app in the Apps list, delete command not.
You can see the Apps list with the command:
pm2 status
So if you stopped, you can restart your app just by its name.
I think the command you want is:
pm2 reload [AppName]
Just replace the files and then run the command.
Source:
http://pm2.keymetrics.io/docs/usage/pm2-doc-single-page/
You can handle the reload signal inside you app, what could be interesting in production. More info:
http://pm2.keymetrics.io/docs/usage/signals-clean-restart/

Resources