summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDylan Thacker-Smith <Dylan.Smith@shopify.com>2014-06-19 02:24:53 -0400
committerDylan Thacker-Smith <Dylan.Smith@shopify.com>2014-06-19 02:36:16 -0400
commita615548bf13ca517c3d991738cf611f2d6accf08 (patch)
treef356215248ab4cbd68969817c4450bf884d090be /lib
parentc49881072556821fc4730b44f1dd6f9afa1bc8d6 (diff)
Close event connections when the server is gracefully shutting down.
Diffstat (limited to 'lib')
-rw-r--r--lib/dashing/app.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/dashing/app.rb b/lib/dashing/app.rb
index 033849c..800f4c8 100644
--- a/lib/dashing/app.rb
+++ b/lib/dashing/app.rb
@@ -6,6 +6,7 @@ require 'coffee-script'
require 'sass'
require 'json'
require 'yaml'
+require 'thin'
SCHEDULER = Rufus::Scheduler.new
@@ -119,6 +120,16 @@ get '/views/:widget?.html' do
end
end
+Thin::Server.class_eval do
+ def stop_with_connection_closing
+ Sinatra::Application.settings.connections.each(&:close)
+ stop_without_connection_closing
+ end
+
+ alias_method :stop_without_connection_closing, :stop
+ alias_method :stop, :stop_with_connection_closing
+end
+
def send_event(id, body, target=nil)
body[:id] = id
body[:updatedAt] ||= Time.now.to_i