Skip to content

Commit

Permalink
REVERT: message bus changes
Browse files Browse the repository at this point in the history
  • Loading branch information
eviltrout committed Dec 8, 2015
1 parent d22a479 commit 4820d5c
Show file tree
Hide file tree
Showing 38 changed files with 84 additions and 95 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ GEM
mail (2.6.3)
mime-types (>= 1.16, < 3)
memory_profiler (0.9.4)
message_bus (1.1.0)
message_bus (1.0.16)
rack (>= 1.1.3)
redis
metaclass (0.0.4)
Expand Down Expand Up @@ -315,7 +315,7 @@ GEM
ffi (>= 1.0.6)
msgpack (>= 0.4.3)
trollop (>= 1.16.2)
redis (3.2.2)
redis (3.2.1)
redis-namespace (1.5.2)
redis (~> 3.0, >= 3.0.4)
ref (2.0.0)
Expand Down
79 changes: 0 additions & 79 deletions config/initializers/004-message_bus.rb

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
57 changes: 57 additions & 0 deletions config/initializers/04-message_bus.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
MessageBus.site_id_lookup do
RailsMultisite::ConnectionManagement.current_db
end

MessageBus.extra_response_headers_lookup do |env|
{
"Access-Control-Allow-Origin" => Discourse.base_url_no_prefix,
"Access-Control-Allow-Methods" => "GET, POST",
"Access-Control-Allow-Headers" => "X-SILENCE-LOGGER, X-Shared-Session-Key"
}
end

MessageBus.user_id_lookup do |env|
user = CurrentUser.lookup_from_env(env)
user.id if user
end

MessageBus.group_ids_lookup do |env|
user = CurrentUser.lookup_from_env(env)
if user && user.admin?
# special rule, admin is allowed access to all groups
Group.pluck(:id)
elsif user
user.groups.pluck('groups.id')
end
end

MessageBus.on_connect do |site_id|
RailsMultisite::ConnectionManagement.establish_connection(db: site_id)
end

MessageBus.on_disconnect do |site_id|
ActiveRecord::Base.connection_handler.clear_active_connections!
end

# Point at our redis
MessageBus.redis_config = GlobalSetting.redis_config

MessageBus.long_polling_enabled = SiteSetting.enable_long_polling
MessageBus.long_polling_interval = SiteSetting.long_polling_interval

MessageBus.is_admin_lookup do |env|
user = CurrentUser.lookup_from_env(env)
if user && user.admin
true
else
false
end
end

MessageBus.cache_assets = !Rails.env.development?
MessageBus.enable_diagnostics

if Rails.env == "test" || $0 =~ /rake$/
# disable keepalive in testing
MessageBus.keepalive_interval = -1
end
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 0 additions & 13 deletions config/initializers/200-message_bus_request_tracker.rb

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ def call(env)

end

# this code plays up, skip for now
#Rails.configuration.middleware.insert_before MessageBus::Rack::Middleware, Discourse::ForceHttpsMiddleware

File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions config/initializers/99-request_tracker.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# no reason to track this in development, that is 300+ redis calls saved per
# page view (we serve all assets out of thin in development)
if Rails.env != 'development' || ENV['TRACK_REQUESTS']
require 'middleware/request_tracker'
Rails.configuration.middleware.unshift Middleware::RequestTracker
end
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions config/initializers/inflections.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Be sure to restart your server when you modify this file.

# Add new inflection rules using the following format
# (all these examples are active by default):
# ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
# end
File renamed without changes.
5 changes: 5 additions & 0 deletions config/initializers/mime_types.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Be sure to restart your server when you modify this file.

# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/demon/sidekiq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def after_fork
cli = Sidekiq::CLI.instance
cli.parse(["-c", GlobalSetting.sidekiq_workers.to_s])

load Rails.root + "config/initializers/100-sidekiq.rb"
load Rails.root + "config/initializers/sidekiq.rb"
cli.run
rescue => e
STDERR.puts e.message
Expand Down

0 comments on commit 4820d5c

Please sign in to comment.