Using pm2 on Windows Server the Node server is not accessible but if I restart using pm2 restart server.js it does become accessible.
I am using pm2-windows-startup to start the server on system boot.
If I run pm2 status after reboot it shows it is running but the service is not available until I run pm2 restart server.js.
Not really a Windows expert... I've already allowed exceptions in the firewall, etc. Any idea on what else could be the problem?
Related
When I restart the ubuntu server the node.js services in the server are not running in the background.
I need to connect to the server and start the services whenever I restart the server.
You need to use pm2 is a advanced process manager for production Node.js applications. Load balancer, logs facility, startup script, micro service management, at a glance.
https://pm2.keymetrics.io/
With this you can run in background
Use PM2.
To install PM2:
npm install -g pm2
To start a node.js process:
pm2 start -n "My task name" /path/to/node/script
To list process:
pm2 list
To restart manually a process (after update for example):
pm2 restart <id of process>
PM2 will handle restart automatically in some case, or you can also tell PM2 to restart node process if script change. And many other cool things.
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.
I have node application hosted in amazon ec2.
I used nginx to point it in my domain.
It runs perfectly when i use npm start to run the application.
But when i use pm2, it doesnt work.
pm2 list command shows that the app is running.
But url doesn't work. Even when i again run npm start app gets started that clearly states that the port is free. So pm2 is not actually running anything on that port. But pm2 says app is online.
I was running the wrong file from pm2. As it was express project, so i had to run bin/www
So the following command solve the issue:
pm2 start bin/www
Answered it here as well:
https://github.com/Unitech/pm2/issues/3252
Thanks
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
I am trying to use the module pm2 to start my node js app everytime the server boots.
I have used the command pm2 startup ubuntu but each time I restart the server, my application is not running and I have to start it manually again.
Any ideas what is causing this issue?
Make sure you do save your processes:
pm2 start app.js
pm2 startup ubuntu
pm2 save
Once you have started the apps and want to keep them on server reboot
do: pm2 save
Source: https://github.com/Unitech/PM2/blob/master/ADVANCED_README.md#startup-script
Go to your server directory and use the following commands:
pm2 start <your_app_name.js>
pm2 startup ubuntu
pm2 save