Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PM2 shows old version when re-building app

Tags:

node.js

pm2

My node-app is running in PM2. When I pull the latest version of my app off github and rebuild it, the site during the building process defaults to a much older version (probably the first version when I initially launched the daemon). How can I make it show the latest version before the fetch, while I rebuild to the really latest version?

like image 963
Ansjovis86 Avatar asked May 24 '18 23:05

Ansjovis86


People also ask

How do you reset pm2 service?

Restart on file change To totally disable the watch feature, do: pm2 stop app --watch or toggle the watch option on application restart via pm2 restart app --watch .

Does pm2 auto restart on file change?

js App in Development Mode with PM2. At this point, your server will auto-restart each time you create, modify or delete a source file in your project. It also works when you add or remove a dependency with npm or yarn .

Does pm2 need to be installed globally?

yes, you need to install it globally.


1 Answers

To serve the latest code in the directory, run:

$ pm2 reload APP_NAME

You can find out APP_NAME by

$ pm2 list

When you fetch the latest code and want to run it, restart the server with

$ pm2 reload APP_NAME

To Start a server for the first time with a specific name

$ pm2 start path/to/index.js --name "api"

Note: On linux you might have to run pm2 with sudo

like image 123
eMad Avatar answered Oct 01 '22 06:10

eMad