First i use pm2 start .pm2.json to start some apps in json. And then i changed the json adding a single line "log_date_format": "YYYY-MM-DD HH:mm" wishing to change the log format.
And then i use pm2 restart .pm2.json, but the log format stayed unchanged.
But pm2 kill & pm2 start .pm2.json worked which would cause downtime.
+1!
This is causing me some problems too, like preventing me to modify the app path in a server with a deploy with Capistrano.
I have a structure like:
- current => 12820
- 12345
- 12820
cd current && pm2 reload ecosystem.json
# Successfully reloaded. App path: /some/path/to/12820/ecosystem.json
Then I deploy a new version and execute the same command:
- current => 13102
- 12345
- 12820
- 13102
cd current && pm2 reload ecosystem.json
# Successfully reloaded. App path: /some/path/to/12820/ecosystem.json
The app has been reloaded but using the old code, as PM2 has only used the ecosystem.json to extract the app name and use the old config. I think the problem is the same.
Any thoughts?
Published a first draft into development branch, so now you will be able to change some stuff in the json and refresh it via restart without deleting + restarting your app
:+1:
pm2 delete all
pm2 start processes.json
Le mar. 20 oct. 2015 Ã 23:38, Adam Ever-Hadani [email protected] a
écrit :
[image: :+1:]
—
Reply to this email directly or view it on GitHub
https://github.com/Unitech/pm2/issues/1650#issuecomment-149710827.
yes would lvoe love love this...
Hello, the JSON configuration reload feature is available on the development, feel free to try and give me any feedback:
$ npm install Unitech/pm2#development -g
PS: it only work for restart
It works fine (including in 1.0.0), though only with restart as you said. I understand that prevents us from doing a 0-downtime restart, right? Any possibility to have it in that case too?
landing in next release (1.0.3)
Update available ([email protected] - latest stable):
$ npm install pm2@latest -g
$ pm2 update
Please re-open this issue if you notice any problem,
@Unitech I'm just upgraded to 1.1.2 and tried to run pm2 startOrGracefulReload config_file.json
And I've got following error:
$ pm2 startOrGracefulReload /etc/config/footprint-proxy-conf.json
[PM2] Applying action softReloadProcessId on app [my-module](ids: 0,1,2,3)
/usr/lib/node_modules/pm2/lib/CLI.js:1034
Object.keys(envs).forEach(function(k) {
^
TypeError: Object.keys called on non-object
at Function.keys (native)
at /usr/lib/node_modules/pm2/lib/CLI.js:1034:18
at /usr/lib/node_modules/pm2/node_modules/async/lib/async.js:181:20
at replenish (/usr/lib/node_modules/pm2/node_modules/async/lib/async.js:319:21)
at /usr/lib/node_modules/pm2/node_modules/async/lib/async.js:330:15
at Object.async.forEachLimit.async.eachLimit (/usr/lib/node_modules/pm2/node_modules/async/lib/async.js:220:35)
at processIds (/usr/lib/node_modules/pm2/lib/CLI.js:1024:11)
at /usr/lib/node_modules/pm2/lib/CLI.js:1134:14
at /usr/lib/node_modules/pm2/lib/Common.js:378:12
at /usr/lib/node_modules/pm2/node_modules/pm2-axon-rpc/lib/client.js:45:10
Thank you.
Hi, any updates here?
pm2 reload|restart myconf.json did not work for me. PM2 restarts all jobs without reloading my changes in the json-file. I still have to delete and start again. (my apps are binaries in fork-mode)
Further I have about 20 apps defined in my json-file, but I have changed the settings for only one app, then it would be crucial that only that one gets restarted. That means something like
pm2 reload myconf.json app1 would be handy.
Otherwise it's a great tool, many thanks.
I'm using pm2 v1.1.3 with Node.js v4.4.5 on CentOS 6.8
$ pm2 reload myconf.json --only app1
@alexindigo the startOrGracefulReload is going to be deprecated, could you try instead pm2 reload config.json, it has the same behavior than startOrGracefulReload (but shorter ;))
@Unitech I'll try it. Thanks. Would it re-read the config file?
@Unitech @alexindigo I'm still having this problem today. Did you manage to figure out a way around this or is delete and start really the only option?
@kmccmk9 Yeah, no dice there. So what we ended up doing, is to take out each server out of rotation, full restart of the services and then bring it back into the loop.
@alexindigo @kmccmk9 Should be working with the latest pm2 version (in last case try with --update-env options but it should be good without)
At the time when I updated pm2 to the latest version it started to crash on start, so we had to revert and go for the workaround.
one@development ~/github/cloudimageshare-monitoring $ pm2 --version
2.5.0
I am having this issue. i had to pm2 delete all to work around. Is this expected behavior? If not, can this bug please be re-opened?
+1, had to pm2 delete ecosystem.config.js and then start.
+1, not reload config on pm2 restart config.yaml
pm2 --version
2.6.1
I am also having this issue. Biting me hard :-(
Please reopen!
I think it'd be useful to have something like pm2 gracefulRestart <config_file> so it'd start new instances with new config and slowly shutdown old ones. Right we have to utilize haproxy for that, which is cumbersome.
Absolutely needed feature.
pm2 restart app.js
should reload the changes in config file. Any update on this?
I think I have the same problem; pm2 delete all solve it, but it seems an overkill.
I change option instances of cluster mode and restart/reload, it doesn't become effective.
@zyf0330 You can use pm2 scale APP 8 to duplicate in 8 processes your application
@vmarchaud Thanks, but I just show an example.
Just a question, now in 2018, is this issue solved, that is,
does pm2 restart <json_file> re-reads the JSON file?
Thanks for the great free tool!
I just ran into this on version 2.10.4, so no, this is not fixed :(.
@Unitech, can you please reopen this ticket?
I had the same issue with capistrano : pm2 restart (and reload) was not reading the right directory. If the first pm2 start was done in a directory, all the restarts will happen in the same directory, even if it's in a "current" symlinked directory.
There are some nice explanations here:
http://pm2.keymetrics.io/docs/tutorials/capistrano-like-deployments
TL;DR: in your ecosystem file, set cwd to your "current" path. Then you will have to delete & start again your app. Once it's done, pm2 restart will look for your new current path.
See https://pm2.io/doc/en/runtime/reference/ecosystem-file/ for cwd documentation.
@Owumaro can confirm it does work this way; thx
I confirm that it does work for .json files
Only can't use it with id and all, took me a bit to realize that :)
Most helpful comment
Hi, any updates here?
pm2 reload|restart myconf.jsondid not work for me. PM2 restarts all jobs without reloading my changes in the json-file. I still have to delete and start again. (my apps are binaries in fork-mode)Further I have about 20 apps defined in my json-file, but I have changed the settings for only one app, then it would be crucial that only that one gets restarted. That means something like
pm2 reload myconf.json app1would be handy.Otherwise it's a great tool, many thanks.
I'm using pm2 v1.1.3 with Node.js v4.4.5 on CentOS 6.8