diff options
Diffstat (limited to 'config/initializers')
-rw-r--r-- | config/initializers/kaminari_config.rb | 3 | ||||
-rw-r--r-- | config/initializers/paperclip.rb | 6 | ||||
-rw-r--r-- | config/initializers/statsd.rb | 23 | ||||
-rw-r--r-- | config/initializers/strong_migrations.rb | 2 |
4 files changed, 16 insertions, 18 deletions
diff --git a/config/initializers/kaminari_config.rb b/config/initializers/kaminari_config.rb index 27b183eeb..aa1517256 100644 --- a/config/initializers/kaminari_config.rb +++ b/config/initializers/kaminari_config.rb @@ -3,6 +3,5 @@ Kaminari.configure do |config| config.default_per_page = 40 config.window = 1 - config.left = 3 - config.right = 1 + config.outer_window = 1 end diff --git a/config/initializers/paperclip.rb b/config/initializers/paperclip.rb index f27aae7ec..2c82a91db 100644 --- a/config/initializers/paperclip.rb +++ b/config/initializers/paperclip.rb @@ -7,6 +7,8 @@ Paperclip.interpolates :filename do |attachment, style| [basename(attachment, style), extension(attachment, style)].delete_if(&:blank?).join('.') end +Paperclip::Attachment.default_options[:use_timestamp] = false + if ENV['S3_ENABLED'] == 'true' Aws.eager_autoload!(services: %w(S3)) @@ -18,7 +20,6 @@ if ENV['S3_ENABLED'] == 'true' Paperclip::Attachment.default_options[:s3_headers] = { 'Cache-Control' => 'max-age=315576000' } Paperclip::Attachment.default_options[:s3_permissions] = ENV.fetch('S3_PERMISSION') { 'public-read' } Paperclip::Attachment.default_options[:s3_region] = ENV.fetch('S3_REGION') { 'us-east-1' } - Paperclip::Attachment.default_options[:use_timestamp] = false Paperclip::Attachment.default_options[:s3_credentials] = { bucket: ENV.fetch('S3_BUCKET'), @@ -48,6 +49,7 @@ elsif ENV['SWIFT_ENABLED'] == 'true' provider: 'OpenStack', openstack_username: ENV.fetch('SWIFT_USERNAME'), openstack_project_name: ENV.fetch('SWIFT_TENANT'), + openstack_tenant: ENV.fetch('SWIFT_TENANT'), # Some OpenStack-v2 ignores project_name but needs tenant openstack_api_key: ENV.fetch('SWIFT_PASSWORD'), openstack_auth_url: ENV.fetch('SWIFT_AUTH_URL'), openstack_domain_name: ENV['SWIFT_DOMAIN_NAME'] || 'default', @@ -55,7 +57,7 @@ elsif ENV['SWIFT_ENABLED'] == 'true' openstack_cache_ttl: ENV['SWIFT_CACHE_TTL'] || 60, }, fog_directory: ENV.fetch('SWIFT_CONTAINER'), - fog_host: ENV.fetch('SWIFT_OBJECT_URL'), + fog_host: ENV['SWIFT_OBJECT_URL'], fog_public: true ) else diff --git a/config/initializers/statsd.rb b/config/initializers/statsd.rb index f00b1d401..17a176174 100644 --- a/config/initializers/statsd.rb +++ b/config/initializers/statsd.rb @@ -1,18 +1,15 @@ # frozen_string_literal: true -RESERVED_CHARACTERS_REGEX = /[\:\|\@]/ -StatsD.prefix = 'mastodon' -StatsD.default_sample_rate = 1 +if ENV['STATSD_ADDR'].present? + host, port = ENV['STATSD_ADDR'].split(':') -def clean_name(str) - str.gsub('::', '.').gsub(RESERVED_CHARACTERS_REGEX, '_') -end - -ActiveSupport::Notifications.subscribe(/performance/) do |name, _start, _finish, _id, payload| - action = payload[:action] || :increment - measurement = payload[:measurement] - value = payload[:value] - key_name = clean_name("#{name}.#{measurement}") + statsd = ::Statsd.new(host, port) + statsd.namespace = ['Mastodon', Rails.env].join('.') - StatsD.send(action.to_s, key_name, (value || 1)) + ::NSA.inform_statsd(statsd) do |informant| + informant.collect(:action_controller, :web) + informant.collect(:active_record, :db) + informant.collect(:cache, :cache) + informant.collect(:sidekiq, :sidekiq) + end end diff --git a/config/initializers/strong_migrations.rb b/config/initializers/strong_migrations.rb index 3d7beac9f..70feb4f11 100644 --- a/config/initializers/strong_migrations.rb +++ b/config/initializers/strong_migrations.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -StrongMigrations.start_after = 20170924022025 if Rails.env.development? +StrongMigrations.start_after = 20170924022025 |