Skip to content

Commit

Permalink
Set SECRET_KEY_BASE for rails job runners
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhughes committed Nov 8, 2023
1 parent 960f2a2 commit d4ccdb8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion cookbooks/dev/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
systemd_service "rails-jobs@" do
description "Rails job queue runner"
type "simple"
environment "RAILS_ENV" => "production", "SLEEP_DELAY" => "60"
environment_file "/etc/default/rails-%i"
user "apis"
working_directory "/srv/%i.apis.dev.openstreetmap.org/rails"
exec_start "#{node[:ruby][:bundle]} exec rails jobs:work"
Expand Down Expand Up @@ -413,6 +413,14 @@
notifies :restart, "rails_port[#{site_name}]"
end

template "/etc/default/rails-#{name}" do
source "rails.environment.erb"
owner "root"
group "root"
mode "0600"
variables :secret_key_base => secret_key_base
end

service "rails-jobs@#{name}" do
action [:enable, :start]
supports :restart => true
Expand Down
5 changes: 5 additions & 0 deletions cookbooks/dev/templates/default/rails.environment.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# DO NOT EDIT - This file is being maintained by Chef

RAILS_ENV="production"
SLEEP_DELAY="60"
SECRET_KEY_BASE="<%= @secret_key_base %>"
5 changes: 4 additions & 1 deletion cookbooks/web/recipes/rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@
systemd_service "rails-jobs@" do
description "Rails job queue runner"
type "simple"
environment "RAILS_ENV" => "production", "QUEUE" => "%I", "SLEEP_DELAY" => "60"
environment "RAILS_ENV" => "production",
"QUEUE" => "%I",
"SLEEP_DELAY" => "60",
"SECRET_KEY_BASE" => web_passwords["secret_key_base"]
user "rails"
working_directory rails_directory
exec_start "#{node[:ruby][:bundle]} exec rails jobs:work"
Expand Down

0 comments on commit d4ccdb8

Please sign in to comment.