Environment variable changes in gitlab.rb not applied to Unicorn after reconfigure
When I edit gitlab_rails['env']
in /etc/gitlab/gitlab.rb and run gitlab-ctl reconfigure
I expect to see any changes this should cause in Unicorn. This does not happen until after I run an additional gitlab-ctl restart unicorn
. The culprit is probably SIGUSR2, which corresponds to gitlab-ctl hup unicorn
.
To see what I mean try the following:
echo '%h1= ENV["FOOBAR"]' | sudo tee -a /opt/gitlab/embedded/service/gitlab-rails/app/views/devise/sessions/new.html.haml
echo 'gitlab_rails["env"] = {"FOOBAR" => "hello" }' | sudo tee -a /etc/gitlab/gitlab.rb
sudo gitlab-ctl reconfigure
- wait for unicorn to restart:
sudo gitlab-ctl tail unicorn
, look for recent "adopted existing unicorn master" message - load
gitlab.example.com/users/sign_in
(while signed out)
Expected: I see large letters 'hello' in the bottom right corner of the screen.
Actual behavior: no 'hello' until after I run gitlab-ctl restart
.
I understand while live-reloading Unicorn is the default behavior (it avoids a 30s blackout with 502 errors while Unicorn restarts) but in the specific case where env variables get updated it might be better if we then automatically do a 'real' restart of Unicorn. In the current situation it is confusing that 'edit config + reconfigure' has no effect on Unicorn until after you run an extra command.
The use case for this is that we want to use environment variables on unicorn/sidekiq as feature flags for Gitaly.