Reload PM2 configuration file

As the reference states, configurations are no longer reloaded:

Starting PM2 v2.1.X, environnements are immutable by default, that means they will never be updated unless you tell PM2 to do so, to update configurations, you will need to use --update-env options.

So this should be

pm2 startOrReload config.js --update-env

If you are using pm2 for local development and have problems with reloading the config you should run:

$ pm2 delete ecosystem.config.js

This deletes existing services (don't worry, no files will be deleted). Then to reload the configuration run:

$ pm2 start ecosystem.config.js

(Tip: you may need to replace ecosystem.config.js with your config file name)

This is a very rough way of reloading, but it's good if you want a clean slate. It's effective to solve some issues, like I had with node-config - I was getting NODE_APP_INSTANCE warnings even though I added instance_var to my ecosystem config.


If you need a COMPLETE PURGE and restart of the configuration:

pm2 kill                                 # kill ongoing pm2 processes
pm2 flush                                # OPTIONAL if logs need to be removed
pm2 start /path/to/ecosystem.config.js   # load config file
pm2 save                                 # save current process list / save changes after loading config file

This can be useful if you keep getting pm2 feedback: status: errored.

If you only want to reload i.e. "refresh" the configuration use this:

pm2 startOrReload config.js --update-env

You should try reload first and if the configuration is still not refreshed, try the complete purge.

Tags:

Node.Js

Pm2