chore: Fix connection pool (#6005)
We want to allocate as much database connection to the pool to match the sidekiq concurrency configuration. ref: https://maxencemalbois.medium.com/the-ruby-on-rails-database-connections-pool-4ce1099a9e9f fixes: #6004
This commit is contained in:
@@ -213,3 +213,8 @@ STRIPE_WEBHOOK_SECRET=
|
|||||||
# Set to true if you want to upload files to cloud storage using the signed url
|
# Set to true if you want to upload files to cloud storage using the signed url
|
||||||
# Make sure to follow https://edgeguides.rubyonrails.org/active_storage_overview.html#cross-origin-resource-sharing-cors-configuration on the cloud storage after setting this to true.
|
# Make sure to follow https://edgeguides.rubyonrails.org/active_storage_overview.html#cross-origin-resource-sharing-cors-configuration on the cloud storage after setting this to true.
|
||||||
DIRECT_UPLOADS_ENABLED=
|
DIRECT_UPLOADS_ENABLED=
|
||||||
|
|
||||||
|
## Advanced configurations
|
||||||
|
## Change these values to fine tune performance
|
||||||
|
# control the concurrency setting of sidekiq
|
||||||
|
# SIDEKIQ_CONCURRENCY=10
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
backend: bin/rails s -p 3000
|
backend: bin/rails s -p 3000
|
||||||
frontend: bin/webpack-dev-server
|
frontend: bin/webpack-dev-server
|
||||||
worker: bundle exec sidekiq -C config/sidekiq.yml
|
# https://github.com/mperham/sidekiq/issues/3090#issuecomment-389748695
|
||||||
|
worker: dotenv bundle exec sidekiq -C config/sidekiq.yml
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
backend: RAILS_ENV=test bin/rails s -p 5050
|
backend: RAILS_ENV=test bin/rails s -p 5050
|
||||||
frontend: bin/webpack-dev-server
|
frontend: bin/webpack-dev-server
|
||||||
worker: RAILS_ENV=test bundle exec sidekiq -C config/sidekiq.yml
|
worker: dotenv RAILS_ENV=test bundle exec sidekiq -C config/sidekiq.yml
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
default: &default
|
default: &default
|
||||||
adapter: postgresql
|
adapter: postgresql
|
||||||
encoding: unicode
|
encoding: unicode
|
||||||
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
|
||||||
host: <%= ENV.fetch('POSTGRES_HOST', 'localhost') %>
|
host: <%= ENV.fetch('POSTGRES_HOST', 'localhost') %>
|
||||||
port: <%= ENV.fetch('POSTGRES_PORT', '5432') %>
|
port: <%= ENV.fetch('POSTGRES_PORT', '5432') %>
|
||||||
|
# ref: https://github.com/mperham/sidekiq/issues/2985#issuecomment-531097962
|
||||||
|
pool: <%= Sidekiq.server? ? Sidekiq.options[:concurrency] : ENV.fetch('RAILS_MAX_THREADS', 5) %>
|
||||||
|
|
||||||
development:
|
development:
|
||||||
<<: *default
|
<<: *default
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
# pick it up automatically.
|
# pick it up automatically.
|
||||||
---
|
---
|
||||||
:verbose: false
|
:verbose: false
|
||||||
:concurrency: 5
|
:concurrency: <%= ENV.fetch("SIDEKIQ_CONCURRENCY", 5) %>
|
||||||
:timeout: 25
|
:timeout: 25
|
||||||
:max_retries: 3
|
:max_retries: 3
|
||||||
|
|
||||||
@@ -30,6 +30,6 @@
|
|||||||
|
|
||||||
# you can override concurrency based on environment
|
# you can override concurrency based on environment
|
||||||
production:
|
production:
|
||||||
:concurrency: 10
|
:concurrency: <%= ENV.fetch("SIDEKIQ_CONCURRENCY", 10) %>
|
||||||
staging:
|
staging:
|
||||||
:concurrency: 5
|
:concurrency: <%= ENV.fetch("SIDEKIQ_CONCURRENCY", 5) %>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ class RemoveNameFromChannels < ActiveRecord::Migration[6.0]
|
|||||||
remove_column :channel_facebook_pages, :name, :string
|
remove_column :channel_facebook_pages, :name, :string
|
||||||
remove_column :channel_twitter_profiles, :name, :string
|
remove_column :channel_twitter_profiles, :name, :string
|
||||||
migrate_web_widget_name_to_inbox
|
migrate_web_widget_name_to_inbox
|
||||||
remove_column :channel_web_widgets, :website_name, :string # rubocop:disable Rails/BulkChangeTable
|
remove_column :channel_web_widgets, :website_name, :string
|
||||||
|
|
||||||
add_column :channel_web_widgets, :welcome_title, :string
|
add_column :channel_web_widgets, :welcome_title, :string
|
||||||
add_column :channel_web_widgets, :welcome_tagline, :string
|
add_column :channel_web_widgets, :welcome_tagline, :string
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class AddSenderToMessages < ActiveRecord::Migration[6.0]
|
|||||||
add_sender_from_message
|
add_sender_from_message
|
||||||
remove_index :messages, name: 'index_messages_on_contact_id', column: 'contact_id'
|
remove_index :messages, name: 'index_messages_on_contact_id', column: 'contact_id'
|
||||||
remove_index :messages, name: 'index_messages_on_user_id', column: 'user_id'
|
remove_index :messages, name: 'index_messages_on_user_id', column: 'user_id'
|
||||||
remove_column :messages, :user_id, :integer # rubocop:disable Rails/BulkChangeTable
|
remove_column :messages, :user_id, :integer
|
||||||
remove_column :messages, :contact_id, :integer
|
remove_column :messages, :contact_id, :integer
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
class AgentAwayMessageToAutoReply < ActiveRecord::Migration[6.0]
|
class AgentAwayMessageToAutoReply < ActiveRecord::Migration[6.0]
|
||||||
def change
|
def change
|
||||||
add_column :inboxes, :greeting_enabled, :boolean, default: false # rubocop:disable Rails/BulkChangeTable
|
add_column :inboxes, :greeting_enabled, :boolean, default: false
|
||||||
add_column :inboxes, :greeting_message, :string
|
add_column :inboxes, :greeting_message, :string
|
||||||
|
|
||||||
migrate_agent_away_to_greeting
|
migrate_agent_away_to_greeting
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ Type=simple
|
|||||||
User=chatwoot
|
User=chatwoot
|
||||||
WorkingDirectory=/home/chatwoot/chatwoot
|
WorkingDirectory=/home/chatwoot/chatwoot
|
||||||
|
|
||||||
ExecStart=/bin/bash -lc 'bundle exec sidekiq -C config/sidekiq.yml'
|
ExecStart=/bin/bash -lc 'dotenv bundle exec sidekiq -C config/sidekiq.yml'
|
||||||
|
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=1
|
RestartSec=1
|
||||||
|
|||||||
Reference in New Issue
Block a user