travis-api/lib/travis/sidekiq.rb
Piotr Sarnacki b68c7a33b0 Allow to set sidekiq concurrency separately from web workers
Unicorn, which we use to serve the API, uses forked workers that need
only one connection per instance. Sidekiq on the other hand runs several
instances in memory, so it needs a higher concurrency setting. This
commit introduces a way to set sidekiq db pool using
SIDEKIQ_DB_POOL_SIZE
2016-03-17 10:57:15 +01:00

30 lines
864 B
Ruby

#$: << './lib'
require 'sidekiq'
require 'travis'
require 'travis/api/workers/build_cancellation'
require 'travis/api/workers/build_restart'
require 'travis/api/workers/job_cancellation'
require 'travis/api/workers/job_restart'
require 'travis/support/amqp'
Travis.config.database[:pool] = ENV['SIDEKIQ_DB_POOL_SIZE'] || 5
Travis::Database.connect
if Travis.config.logs_database
Log.establish_connection 'logs_database'
Log::Part.establish_connection 'logs_database'
end
Travis::Async.enabled = true
Travis::Amqp.config = Travis.config.amqp
Travis::Metrics.setup
Travis::Notification.setup
Sidekiq.configure_server do |config|
config.redis = Travis.config.redis.merge(namespace: Travis.config.sidekiq.namespace)
end
Sidekiq.configure_client do |config|
config.redis = Travis.config.redis.merge(size: 1, namespace: Travis.config.sidekiq.namespace)
end