Enable/disable delayed jobs in the secrets file

While this is not a secret and in theory should be in a file under
version control, currently the CONSUL installer disables delayed jobs by
default, meaning we were keeping two versions of the delayed jobs
configuration file, and some existing configurations have their settings
defined in a file in capistrano's `shared` folder.

So we're moving existing settings to the secrets file.
This commit is contained in:
Javi Martín
2019-11-02 21:58:28 +01:00
parent 6ecd9e59dc
commit a08d42d3f8
4 changed files with 14 additions and 7 deletions

View File

@@ -47,7 +47,7 @@ namespace :deploy do
after "deploy:migrate", "add_new_settings"
before :publishing, "smtp_and_ssl_secrets"
before :publishing, "smtp_ssl_and_delay_jobs_secrets"
after :publishing, "deploy:restart"
after :published, "delayed_job:restart"
@@ -131,7 +131,7 @@ task :setup_puma do
end
end
task :smtp_and_ssl_secrets do
task :smtp_ssl_and_delay_jobs_secrets do
on roles(:app) do
within current_path do
with rails_env: fetch(:rails_env) do
@@ -141,7 +141,7 @@ task :smtp_and_ssl_secrets do
begin
execute "cp #{release_path}/#{tasks_file_path} #{current_path}/#{tasks_file_path}"
execute :rake, "secrets:smtp_and_ssl"
execute :rake, "secrets:smtp_ssl_and_delay_jobs"
ensure
execute "rm #{current_path}/#{tasks_file_path}"
end

View File

@@ -1,8 +1,11 @@
if Rails.env.test? || Rails.env.development?
Delayed::Worker.delay_jobs = false
else
elsif Rails.application.secrets.delay_jobs.nil?
Delayed::Worker.delay_jobs = true
else
Delayed::Worker.delay_jobs = Rails.application.secrets.delay_jobs
end
Delayed::Worker.destroy_failed_jobs = false
Delayed::Worker.sleep_delay = 2
Delayed::Worker.max_attempts = 3

View File

@@ -33,6 +33,7 @@ staging:
secret_key_base: ""
server_name: ""
force_ssl: true
delay_jobs: true
rollbar_server_token: ""
http_basic_username: ""
http_basic_password: ""
@@ -55,6 +56,7 @@ preproduction:
# authentication: "plain"
# enable_starttls_auto: true
force_ssl: true
delay_jobs: true
rollbar_server_token: ""
http_basic_username: ""
http_basic_password: ""
@@ -82,6 +84,7 @@ production:
# authentication: "plain"
# enable_starttls_auto: true
force_ssl: true
delay_jobs: true
rollbar_server_token: ""
http_basic_username: ""
http_basic_password: ""

View File

@@ -1,10 +1,11 @@
namespace :secrets do
desc "Add SMTP and SSL settings to secrets.yml"
task smtp_and_ssl: :environment do
desc "Add SMTP, SSL and delay jobs settings to secrets.yml"
task smtp_ssl_and_delay_jobs: :environment do
current_settings = {
"mailer_delivery_method" => ActionMailer::Base.delivery_method.to_s,
"smtp_settings" => ActionMailer::Base.smtp_settings.stringify_keys,
"force_ssl" => Rails.application.config.force_ssl
"force_ssl" => Rails.application.config.force_ssl,
"delay_jobs" => Delayed::Worker.delay_jobs
}
settings_to_add = current_settings.select do |name, _|