Skip to content

Commit b902846

Browse files
committed
Close socket, not driver.
1 parent f74bb9c commit b902846

File tree

5 files changed

+18
-8
lines changed

5 files changed

+18
-8
lines changed

.rubocop_todo.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2018-08-27 14:23:13 +0200 using RuboCop version 0.58.2.
3+
# on 2018-09-08 18:09:56 -0400 using RuboCop version 0.58.2.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -16,6 +16,11 @@ Layout/IndentHeredoc:
1616
- 'sample_apps/sample_app_activerecord/commands/help.rb'
1717
- 'sample_apps/sample_app_mongoid/commands/help.rb'
1818

19+
# Offense count: 1
20+
Lint/HandleExceptions:
21+
Exclude:
22+
- 'lib/slack-ruby-bot-server/ping.rb'
23+
1924
# Offense count: 3
2025
# Configuration parameters: Blacklist.
2126
# Blacklist: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))

Gemfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ else
1616
warn "Invalid ENV['DATABASE_ADAPTER']: #{ENV['DATABASE_ADAPTER']}."
1717
end
1818

19-
gem 'slack-ruby-bot', github: 'dblock/slack-ruby-bot', branch: 'async'
20-
gem 'slack-ruby-client', github: 'dblock/slack-ruby-client', branch: 'async'
21-
2219
gemspec
2320

2421
group :development, :test do

lib/slack-ruby-bot-server/ping.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,14 @@ def down!
7272
end
7373

7474
def restart!
75-
logger.warn "RESTART: #{owner}, #{driver}"
76-
driver.close if driver
75+
logger.warn "RESTART: #{owner}"
76+
begin
77+
connection.close
78+
rescue Async::Wrapper::Cancelled
79+
# ignore, from connection.close
80+
end
81+
driver.close
82+
driver.emit(:close, WebSocket::Driver::CloseEvent.new(1001, 'bot offline'))
7783
rescue StandardError => e
7884
logger.warn "Error restarting team #{owner.id}: #{e.message}."
7985
end
@@ -102,6 +108,10 @@ def driver
102108
socket.instance_variable_get(:@driver) if socket
103109
end
104110

111+
def connection
112+
driver.instance_variable_get(:@socket) if driver
113+
end
114+
105115
def logger
106116
@logger ||= begin
107117
STDOUT.sync = true

sample_apps/sample_app_activerecord/Gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ gem 'pg'
77
gem 'rack-server-pages'
88
gem 'rack-test'
99
gem 'slack-ruby-bot-server', path: '../../'
10-
gem 'slack-ruby-client', github: 'dblock/slack-ruby-client', branch: 'async'
1110

1211
group :development, :test do
1312
gem 'standalone_migrations', '~> 5.2'

sample_apps/sample_app_mongoid/Gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ source 'https://rubygems.org'
33
gem 'mongoid'
44
gem 'newrelic-slack-ruby-bot'
55
gem 'slack-ruby-bot-server', path: '../../'
6-
gem 'slack-ruby-client', github: 'dblock/slack-ruby-client', branch: 'async'
76

87
gem 'kaminari-mongoid'
98
gem 'mongoid-scroll'

0 commit comments

Comments
 (0)