Fix the build.
This commit is contained in:
parent
36f8697a59
commit
9dcb11f553
|
@ -126,7 +126,7 @@ module Jobs
|
||||||
begin
|
begin
|
||||||
exception = {}
|
exception = {}
|
||||||
|
|
||||||
RailsMultisite::ConnectionManagement.with_connection(db: db) do
|
RailsMultisite::ConnectionManagement.with_connection(db) do
|
||||||
begin
|
begin
|
||||||
I18n.locale = SiteSetting.default_locale || "en"
|
I18n.locale = SiteSetting.default_locale || "en"
|
||||||
I18n.ensure_all_loaded!
|
I18n.ensure_all_loaded!
|
||||||
|
|
|
@ -65,7 +65,7 @@ module Scheduler
|
||||||
db, job, desc = @queue.deq(non_block)
|
db, job, desc = @queue.deq(non_block)
|
||||||
db ||= RailsMultisite::ConnectionManagement::DEFAULT
|
db ||= RailsMultisite::ConnectionManagement::DEFAULT
|
||||||
|
|
||||||
RailsMultisite::ConnectionManagement.with_connection(db: db) do
|
RailsMultisite::ConnectionManagement.with_connection(db) do
|
||||||
begin
|
begin
|
||||||
job.call
|
job.call
|
||||||
rescue => ex
|
rescue => ex
|
||||||
|
|
|
@ -77,7 +77,7 @@ module Scheduler
|
||||||
@mutex.synchronize { info.write! }
|
@mutex.synchronize { info.write! }
|
||||||
|
|
||||||
if @manager.enable_stats
|
if @manager.enable_stats
|
||||||
RailsMultisite::ConnectionManagement.with_connection(db: "default") do
|
RailsMultisite::ConnectionManagement.with_connection("default") do
|
||||||
stat = SchedulerStat.create!(
|
stat = SchedulerStat.create!(
|
||||||
name: klass.to_s,
|
name: klass.to_s,
|
||||||
hostname: hostname,
|
hostname: hostname,
|
||||||
|
@ -102,7 +102,7 @@ module Scheduler
|
||||||
info.prev_result = failed ? "FAILED" : "OK"
|
info.prev_result = failed ? "FAILED" : "OK"
|
||||||
info.current_owner = nil
|
info.current_owner = nil
|
||||||
if stat
|
if stat
|
||||||
RailsMultisite::ConnectionManagement.with_connection(db: "default") do
|
RailsMultisite::ConnectionManagement.with_connection("default") do
|
||||||
stat.update!(
|
stat.update!(
|
||||||
duration_ms: duration,
|
duration_ms: duration,
|
||||||
live_slots_finish: GC.stat[:heap_live_slots],
|
live_slots_finish: GC.stat[:heap_live_slots],
|
||||||
|
|
|
@ -1,6 +1,24 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe "Running Sidekiq Jobs in Multisite" do
|
RSpec.describe "Running Sidekiq Jobs in Multisite" do
|
||||||
|
let(:conn) { RailsMultisite::ConnectionManagement }
|
||||||
|
|
||||||
|
before do
|
||||||
|
conn.config_filename = "spec/fixtures/multisite/two_dbs.yml"
|
||||||
|
conn.load_settings!
|
||||||
|
conn.remove_class_variable(:@@current_db)
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
conn.clear_settings!
|
||||||
|
|
||||||
|
[:@@db_spec_cache, :@@host_spec_cache, :@@default_spec].each do |class_variable|
|
||||||
|
conn.remove_class_variable(class_variable)
|
||||||
|
end
|
||||||
|
|
||||||
|
conn.set_current_db
|
||||||
|
end
|
||||||
|
|
||||||
it 'should revert back to the default connection' do
|
it 'should revert back to the default connection' do
|
||||||
expect(RailsMultisite::ConnectionManagement.current_db)
|
expect(RailsMultisite::ConnectionManagement.current_db)
|
||||||
.to eq('default')
|
.to eq('default')
|
||||||
|
|
Loading…
Reference in New Issue