I have problems with reloading PM2 configuration file after editing it:
{
"apps": [
...
{
"name": "foo",
"script": "foo/index.js",
"cwd": "foo",
"watch": false
}
]
}
I previously did
pm2 restart config.json
and
pm2 reload config.json
and
pm2 gracefulReload config.json
but they didn't reload the configuration for existing apps (the changes in app config did not apply). The only way that worked for me was:
pm2 delete foo
pm2 restart config.json
How is this supposed to be done?
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 .
With reload, pm2 restarts all processes one by one, always keeping at least one process running. It also states that: If the reload system hasn't managed to reload your application, a timeout will fallback to a classic restart.
The default configuration file is ecosystem. core3. config. js , and is located in the root folder of lisk-service : It contains a configuration to connect to a local Lisk Core node.
PM2 is an advanced, production process manager for Node. js that auto-restarts Node apps after crashes or file changes.
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 love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With