From 9a65ea93d1b4c2c5647a208931284670db2c460f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phan=20Mestach?= Date: Mon, 13 Feb 2023 11:53:14 +0100 Subject: [PATCH 1/2] Use hostname when dynoid not provided --- app/workers/invoice_for_project_anchor_worker.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/workers/invoice_for_project_anchor_worker.rb b/app/workers/invoice_for_project_anchor_worker.rb index 2b338603..2cb9d8d5 100644 --- a/app/workers/invoice_for_project_anchor_worker.rb +++ b/app/workers/invoice_for_project_anchor_worker.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +hostname = `hostname`.strip() + class InvoiceForProjectAnchorWorker include Sidekiq::Worker include Sidekiq::Throttled::Worker @@ -11,7 +13,7 @@ class InvoiceForProjectAnchorWorker sidekiq_throttle( concurrency: { limit: ENV.fetch("SDKQ_MAX_CONCURRENT_INVOICE", 3).to_i }, key_suffix: ->(project_anchor_id, _year, _quarter, _selected_org_unit_ids = nil, _options = {}) { - per_process_id = ENV.fetch("HEROKU_DYNO_ID", $PROCESS_ID) + per_process_id = ENV.fetch("HEROKU_DYNO_ID", hostname) [project_anchor_id, per_process_id].join("-") } ) From 829a4344e0e29a2452bb2e3ca0db84a2d064808d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phan=20Mestach?= Date: Tue, 14 Feb 2023 14:21:28 +0100 Subject: [PATCH 2/2] Put the container and process id --- app/workers/invoice_for_project_anchor_worker.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/workers/invoice_for_project_anchor_worker.rb b/app/workers/invoice_for_project_anchor_worker.rb index 2cb9d8d5..00f8fa0d 100644 --- a/app/workers/invoice_for_project_anchor_worker.rb +++ b/app/workers/invoice_for_project_anchor_worker.rb @@ -13,7 +13,7 @@ class InvoiceForProjectAnchorWorker sidekiq_throttle( concurrency: { limit: ENV.fetch("SDKQ_MAX_CONCURRENT_INVOICE", 3).to_i }, key_suffix: ->(project_anchor_id, _year, _quarter, _selected_org_unit_ids = nil, _options = {}) { - per_process_id = ENV.fetch("HEROKU_DYNO_ID", hostname) + per_process_id = ENV.fetch("HEROKU_DYNO_ID", "#{hostname}-#{$PROCESS_ID}") [project_anchor_id, per_process_id].join("-") } )