NodeJS changes not reflected on server - node.js

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

Related

Nodejs API doesn't work after reboot centos server

In my centos server, I have an API with node js and I started with pm2. pm2 status is online and It works correctly. but when server reboot, can't connect to the API although pm2 status is online.
I also try start node js like below
pm2 start index.js
pm2 startup
pm2 save
but It does not work until I restart pm2 ..
how can I fix it?
You have to do pm2 resurrect to start an application after "pm2 saving" it:
pm2 resurrect
Then put this command in a script file and configure it to run on server reboot. Read this Q and A for help. Also in this article there are some CentOS specific changes that need to be done.

Controller File Updated on Nginx But Server still serves old content

I recently made some changes to one of my controllers on my nodejs application, the changes work fine locally, but when I deploy to the production server, though the changes reflect in the code on the server, it still serves the old version of the file. Am I missing out something?
I've tried restarting the server using
sudo systemctl restart nginx
Result stays the same.
Also tried redeploying, even tried to break the code and push it like that, yet all I get is the same old version. Any solution?
P.S I use PM2 in starting the app
I finally fixed it! Turns out I had to restart pm2 and not nginx. So I just ran
pm2 reload APP_NAME
And it updates
P.S You can know what APP_NAME is by running pm2 list

How to deploy a NodeJS app without root access, so it stays online after server restarts?

I'm trying to deploy my NodeJS app. I tried npm forever and pm2, but I believe that my hoster restarts the server every night because my app is always offline the next day.
The thing is, that I have a shared hosting server on A2hosting and don't have root access, so these sudo commands don't work here... except you know how I can change that, haha...
I don't know what infos I need to provide for you to help me... so if you need to know something, tell me please!
Thank you so much!
I've used pm2 to do that.
npm install -g pm2
then you run the following command to ensure pm2 will run on startup:
pm2 startup
It will show you the command you have to run.
Finally, you initiate the process:
pm2 start server.js --name <service-name>
Freeze your process list:
pm2 save
More details on pm2 documentation: https://github.com/Unitech/pm2

How to run node.js application on pm2

I am new to pm2 manager and ssh. I developed one project in node.js and hosted into pm2 and ssh.That's Working fine and give correct output
Now my question is
Same way i hosted another project into pm2 server and then i follow below procedure to run this application.
Step1: ssh and Mycredentials
step2: cd folder projectname
step3 : pm2 start www
That shows Done.
I will run url i didn't get output default it shows first project ouput\
please help me!
Start your pm2 service with name argument to differentiate with multiple services
pm2 start www --name="my-sample-app1"
pm2 start index.js --name="my-sample-app2"
In order to list out the running process, enter the following command,
pm2 list
Using this you can debug the list of running process
To know the detailed information about your running process, use the following command
pm2 show my-sample-app1
pm2 show my-sample-app2
i tried but not working.
pm2 stop appname
pm2 delete appname
After enter above commands it show process is deleted,Then i enter second project and
pm2 start www
but i got first project output

Website stops working nodejs

I have website on Ubuntu sever.
I have started process using this command
sudo pm2 start app.js -i 0
it was working fine.Today morning my client message me it's stop working.
I have stoped the node and re-start the process again using same command.
Now I want to know the reason by this happens?
How i can do this to check the issue ?
Thanks
check pm2 logs folder ( PM2_PROCESS_USER_HOME_DIRECTORY/.pm2/logs)
May be server crash and you did't setup pm2 autostart
active pm2 autostart :
pm2 startup ubuntu
pm2 save

Resources