-
Notifications
You must be signed in to change notification settings - Fork 0
/
tas.rb
43 lines (34 loc) · 1.14 KB
/
tas.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
require 'sinatra'
require 'sinatra/reloader' if development?
require 'sinatra/streaming'
require 'sprockets'
require 'rmagick'
require 'rufus-scheduler'
require 'coffee-script'
require 'sass'
require 'json'
require_relative 'lib/events'
SCHEDULER = Rufus::Scheduler.start_new
set :root, Dir.pwd
set :public_folder, File.join(settings.root, 'public')
set :views, File.join(settings.root, 'views')
set :sprockets, Sprockets::Environment.new(settings.root)
set :assets_prefix, '/assets'
set :digest_assets, false
['assets/javascripts', 'assets/stylesheets', 'assets/fonts', 'assets/images']. each do |path|
settings.sprockets.append_path path
end
set server: 'thin', connections: [], history: {}
get '/' do
erb :index
end
get '/events', provides: 'text/event-stream' do
response.headers['X-Accel-Buffering'] = 'no' # Disable buffering for nginx
stream :keep_open do |out|
settings.connections << out
out << latest_events
out.callback { settings.connections.delete(out) }
end
end
Dir[File.join(settings.root, 'lib', '**', '*.rb')].each {|file| require file }
Dir[File.join(settings.root, 'jobs', '**', '*.rb')].each {|file| require file }