-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PM2 restart "services.json" doesn't update environment variables #528
Comments
On restart pm2 will not reload |
+1 - exporting the regular to environment variables (via |
I would prefer to preserve environment on restart without changes. If you want to change the value of an ENV var, it's better to |
Our use case is continuous deployment. One of the environment variables is the hash of the last GitHub commit, which becomes available on the client so we can tell which version it's running. This variable would change with every restart. |
Is it possible to merge the environment somehow? So you can do |
If I need to change variables in an application I usually use a configuration file not ENV variables so I really don't know why they would need to be changed once the application has been started. Of course, that's only a point of view. |
@soyuka, I agree with you, but Meteor forces us to use environment variables instead of config files. Maybe you could mention in that ticket your thoughts on this? |
That environment variable looks really weird. But it is a valid use-case, and if some applications use it, pm2 should probably support it. |
The 0.10.0 fixing this issue has been published:
Now environment variable are refreshed on restart (via CLI and via JSON declaration) |
Does this work for startOrRestart? |
Don't work for me using pm2 0.10.8 |
Sorry, I was using pm2 restart appName and not pm2 restart configFile.json Everything is working now. Thanks. |
But startOrRestart really doesn't work. |
I'm trying to figure out how one is supposed to refresh an environment variable for a cluster that is doing 0 downtime reloads using:
It seems that the refresh of environment was only implemented with Is it intentional that changes to the .JSON file are not picked up by PM2 when a |
+1 @mykwillis Would like to have a way to gracefully load a new environment configuration. |
+1 -- this would be very useful -- found that pm2 restart didn't even work -- I had to do pm2 delete; pm2 start xxx.json |
+1 without this feature I can't perform zero downtime deploy |
+1 This is a much needed feature to have reload / gracefulReload refresh env vars. |
It's not the case for reload / gracefulReload, but this feature is available for restarts with PM2 1.0: You can try it: $ npm install Unitech/pm2#development -g You can also restart with different pre-defined environment variables via $ pm2 restart services.json --env production |
Also agree. Would definitely like the ability to update env with zero downtime. i.e. reload |
+1 |
1 similar comment
+1 |
@gflandre @Florelli did you try the development version? |
@soyuka no I haven't yet (our issue is with production use, so it requires us to use a stable version). |
I've ran into this problem too, I need it to reload the environment variables. I couldn't get it to do it until I deleted the process itself from PM2 and started it as if it was new. |
Any update on this? We have th same issue with 2.1.3 although we do not use the json file. |
Same issue ... |
See |
@vmarchaud seems not to affect log file configuration changes though... |
Yeah some options aren't updated, we are thinking about changing this behavior but it has some pro and cons. |
+1 |
Reminder : You need to pass the |
@vmarchaud the bash history shows that I used # pm2 restart ecosystem.json
[PM2] Applying action restartProcessId on app [UEMINA](ids: 0)
[PM2] [UEMINA](0) ✓ and the change of |
@Zing22 You should update, behavior have changed around 2.x if i correctly recall |
@vmarchaud Problem still there, BTW, the exec mode is anyway, thanks for your time : ) |
@Zing22 You can dump the process data using |
Ok so maybe I'm taking crazy pills or something, but I keep having persistent problems with ENV vars and code/assets just downright not updating when I do a On a prior project, I had some static web assets being served from an express server, and said assets would just refuse to update unless I first deleted the pm2 process and restarted it. There's no mechanism for doing this even intentionally that I'm aware of, and it caused many hours of frustration over many weeks, and ultimately required writing a simple bash script to stop/delete/start the process on deployment because it just wasn't working out of the box. More context: I'm using All other process managers I've worked with do a CLEAN RESTART from scratch when you restart them. There should be no state left on the process via PM2 or any other portion of the stack. If I can't get this figured out in a sensible way I'm going to have to drop PM2 entirely for my sanity's sake :-) |
Although this issue was closed in 2014, I still see weird behavior around restarts, even with tiny example projects. The only consistent solution I have is to run |
please fix this broken, complex and useless functionality. Env Vars are Env Vars, not JSON, not YML, not ecosystems, not anything different to a EXPORT VAR=VALUE and process.env returning the correct value. |
This is indeed not fix, and actually I find it more and more unreliable with the latest version Before, I could just pm2 update, now I often need to kill and reload everything, making no downtime reload impossible... |
Seems to me that the only salient plan of action at this point is to stop using this solution in its entirety. Definitely had some potential and great things going for it, but the maintainers don't seem to be taking this seriously enough--at least for my production needs. |
Okay, this problem come in 2022 |
Still a problem in 2023. |
What alternatives is there? i'd love to know what you use now |
Kubernetes 😂 |
Ah! I doubt Kubernetes beats the simplicity of pm2 though... I'll try it nonetheless thanks!
…________________________________
From: Adam Robertson ***@***.***>
Sent: Tuesday, July 25, 2023 6:53:34 PM
To: Unitech/pm2 ***@***.***>
Cc: Osama Zakarneh ***@***.***>; Comment ***@***.***>
Subject: Re: [Unitech/pm2] PM2 restart "services.json" doesn't update environment variables (#528)
Seems to me that the only salient plan of action at this point is to stop using this solution in its entirety. Definitely had some potential and great things going for it, but the maintainers don't seem to be taking this seriously enough--at least for my production needs.
What alternatives is there? i'd love to know what you use now
Kubernetes 😂
—
Reply to this email directly, view it on GitHub<#528 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AHOPLCSURVMLLAU7IKGADZ3XR7TX5ANCNFSM4AQXXIMA>.
You are receiving this because you commented.Message ID: ***@***.***>
|
@Ozak93 absolutely not. While it's definitely not analogous to PM2, having pods for each process with health checks was functionally the same for us. It's a direction we wanted to head anyway, definitely a massive time investment, but you get to feel like a sorcerer when you're done 😆 |
We're using a JSON file to define all our node services and their appropriate environment variables, script starting points etc.
When adding an environment variable for one of our services and issuing
pm2 restart services.json
it doesn't actually add the environment variable to the process (tested usingpm2 dump
).Deleting all the services and adding them again does work though but takes down our API's for a while.
The text was updated successfully, but these errors were encountered: