Open
Description
The following piece of code handle environment variable reloads in Spring
spring/lib/spring/application.rb
Lines 163 to 167 in 770b2b1
What it does is:
- iterate over environment variables from when spring was started and remove those that rails did not change
- iterate over client environment variables and if those are not present in the environment already, replace them
My problem is that I have a Rails application where there is an environment variable that triggers if the app is in master mode or slave mode. I use ENV! to manage environment variable, and if a variable is not set, ENV! sets a default value. The following sequence of events cause an issue:
- spring server starts without the MASTER environment variable
- app sets MASTER=false which is its default value
- some time later...
- I start the app again with MASTER=true on the command-line
- Spring server receives a client request with MASTER=true
- the process above is followed:
- it considers MASTER to be unset when the spring server started but it has now MASTER=false. It received a client request with MASTER=true
- it does not removes MASTER from the environment because it sees the variable changed (fron no value to false)
- it does not replace MASTER=false with MASTER=true because it already has a value.
- the app is started in slave mode despite having specified MASTER=true on the command-line.
I don't know the rationale behind this code, but in some cases it is completely wrong.
I believe this might be a reason behing the #420 issue
Metadata
Metadata
Assignees
Labels
No labels