diff options
author | Varac <varac@leap.se> | 2017-10-16 14:21:55 +0200 |
---|---|---|
committer | Varac <varac@leap.se> | 2017-10-16 14:21:55 +0200 |
commit | c3e807eb42ea7389676b714584bde204eab18577 (patch) | |
tree | d9ac909ff468ff2f00f03a29ab3f9b4ba05a56a7 /lib/dashing | |
parent | 64a3927db5440fe2c9b5c4d02667cb0749884c40 (diff) | |
parent | 2917ad9519d6f872d51582d335a147bf2e5f935e (diff) |
Merge branch 'upgrade_dashing'
Diffstat (limited to 'lib/dashing')
-rw-r--r-- | lib/dashing/app.rb | 15 | ||||
-rw-r--r-- | lib/dashing/cli.rb | 6 |
2 files changed, 14 insertions, 7 deletions
diff --git a/lib/dashing/app.rb b/lib/dashing/app.rb index b11352d..53ee0dc 100644 --- a/lib/dashing/app.rb +++ b/lib/dashing/app.rb @@ -34,16 +34,18 @@ set :root, Dir.pwd set :sprockets, Sprockets::Environment.new(settings.root) set :assets_prefix, '/assets' set :digest_assets, false -set server: 'thin', connections: [], history_file: 'history.yml' +set :server, 'thin' +set :connections, [] +set :history_file, 'history.yml' set :public_folder, File.join(settings.root, 'public') set :views, File.join(settings.root, 'dashboards') set :default_dashboard, nil set :auth_token, nil if File.exists?(settings.history_file) - set history: YAML.load_file(settings.history_file) + set :history, YAML.load_file(settings.history_file) else - set history: {} + set :history, {} end %w(javascripts stylesheets fonts images).each do |path| @@ -55,7 +57,7 @@ end end not_found do - send_file File.join(settings.public_folder, '404.html'), status: 404 + send_file File.join(settings.public_folder, '404.html'), :status => 404 end at_exit do @@ -70,7 +72,7 @@ get '/' do redirect "/" + dashboard end -get '/events', provides: 'text/event-stream' do +get '/events', :provides => 'text/event-stream' do protected! response.headers['X-Accel-Buffering'] = 'no' # Disable buffering for nginx stream :keep_open do |out| @@ -121,6 +123,7 @@ get '/views/:widget?.html' do file = File.join(settings.root, "widgets", params[:widget], "#{params[:widget]}.#{suffix}") return engines.first.new(file).render if File.exist? file end + "Drats! Unable to find a widget file named: #{params[:widget]} to render." end Thin::Server.class_eval do @@ -135,7 +138,7 @@ end def send_event(id, body, target=nil) body[:id] = id - body[:updatedAt] ||= Time.now.to_i + body[:updatedAt] ||= (Time.now.to_f * 1000.0).to_i event = format_event(body.to_json, target) Sinatra::Application.settings.history[id] = event unless target == 'dashboards' Sinatra::Application.settings.connections.each { |out| out << event } diff --git a/lib/dashing/cli.rb b/lib/dashing/cli.rb index 4b93f89..57d48d0 100644 --- a/lib/dashing/cli.rb +++ b/lib/dashing/cli.rb @@ -86,7 +86,11 @@ module Dashing private def run_command(command) - system(command) + begin + system(command) + rescue Interrupt => e + say "Exiting..." + end end def install_widget_from_gist(gist, skip_overwrite) |