Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shutdown pubsub connection before classes are reloaded #26620

Merged
merged 3 commits into from
Oct 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions actioncable/lib/action_cable/server/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ def restart
connections.each(&:close)

@mutex.synchronize do
worker_pool.halt if @worker_pool

# Shutdown the worker pool
@worker_pool.halt if @worker_pool
@worker_pool = nil

# Shutdown the pub/sub adapter
@pubsub.shutdown if @pubsub
@pubsub = nil
end
end

Expand Down
33 changes: 33 additions & 0 deletions actioncable/test/server/base_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require "test_helper"
require "stubs/test_server"
require "active_support/core_ext/hash/indifferent_access"

class BaseTest < ActiveSupport::TestCase
def setup
@server = ActionCable::Server::Base.new
@server.config.cable = { adapter: "async" }.with_indifferent_access
end

class FakeConnection
def close
end
end

test "#restart closes all open connections" do
conn = FakeConnection.new
@server.add_connection(conn)

conn.expects(:close)
@server.restart
end

test "#restart shuts down worker pool" do
@server.worker_pool.expects(:halt)
@server.restart
end

test "#restart shuts down pub/sub adapter" do
@server.pubsub.expects(:shutdown)
@server.restart
end
end