switch to puma, make app reload in development mode
This commit is contained in:
parent
03595db5fa
commit
d4404b201c
2
Gemfile
2
Gemfile
|
@ -2,7 +2,7 @@ ruby '1.9.3' rescue nil
|
|||
|
||||
source :rubygems
|
||||
|
||||
gem 'unicorn'
|
||||
gem 'puma'
|
||||
gem 'rack-ssl', '~> 1.3'
|
||||
gem 'rack-cache'
|
||||
|
||||
|
|
10
Gemfile.lock
10
Gemfile.lock
|
@ -43,15 +43,15 @@ GEM
|
|||
guard (1.4.0)
|
||||
listen (>= 0.4.2)
|
||||
thor (>= 0.14.6)
|
||||
kgio (2.7.4)
|
||||
listen (0.5.3)
|
||||
multi_json (1.3.6)
|
||||
puma (1.6.3)
|
||||
rack (~> 1.2)
|
||||
rack (1.4.1)
|
||||
rack-cache (1.2)
|
||||
rack (>= 0.4)
|
||||
rack-ssl (1.3.2)
|
||||
rack
|
||||
raindrops (0.10.0)
|
||||
rake (0.9.2.2)
|
||||
rb-fsevent (0.9.2)
|
||||
rerun (0.7.1)
|
||||
|
@ -62,10 +62,6 @@ GEM
|
|||
uglifier (1.3.0)
|
||||
execjs (>= 0.3.0)
|
||||
multi_json (~> 1.0, >= 1.0.2)
|
||||
unicorn (4.4.0)
|
||||
kgio (~> 2.6)
|
||||
rack
|
||||
raindrops (~> 0.7)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
@ -76,6 +72,7 @@ DEPENDENCIES
|
|||
debugger
|
||||
foreman
|
||||
guard
|
||||
puma
|
||||
rack-cache
|
||||
rack-ssl (~> 1.3)
|
||||
rake (~> 0.9.2)
|
||||
|
@ -85,4 +82,3 @@ DEPENDENCIES
|
|||
rerun
|
||||
tilt
|
||||
uglifier
|
||||
unicorn
|
||||
|
|
2
Procfile
2
Procfile
|
@ -1,3 +1,3 @@
|
|||
web: script/server
|
||||
web: bundle exec rackup -s puma -p $PORT
|
||||
assets: rerun -x -p 'assets/**/*' 'bundle exec rakep'
|
||||
#specs: rerun -x -p 'public/**/*' './run_jasmine.coffee public/spec.html'
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
# http://michaelvanrooijen.com/articles/2011/06/01-more-concurrency-on-a-single-heroku-dyno-with-the-new-celadon-cedar-stack/
|
||||
|
||||
worker_processes 3 # amount of unicorn workers to spin up
|
||||
timeout 30 # restarts workers that hang for 15 seconds
|
|
@ -17,6 +17,11 @@ class Travis::Web::App
|
|||
end
|
||||
end
|
||||
|
||||
def self.new(options = {})
|
||||
return super unless options[:environment] == 'development'
|
||||
proc { |e| super.call(e) } # poor man's reloader
|
||||
end
|
||||
|
||||
attr_reader :app, :router, :environment, :version, :last_modified, :age, :options, :root
|
||||
|
||||
def initialize(options = {})
|
||||
|
@ -62,9 +67,8 @@ class Travis::Web::App
|
|||
end
|
||||
|
||||
def each_file
|
||||
Dir.chdir(root) do
|
||||
Dir.glob('**/*') { |f| yield f if File.file? f }
|
||||
end
|
||||
pattern = File.join(root, '**/*')
|
||||
Dir.glob(pattern) { |f| yield f if File.file? f }
|
||||
end
|
||||
|
||||
def prefix?(file)
|
||||
|
@ -72,19 +76,20 @@ class Travis::Web::App
|
|||
end
|
||||
|
||||
def index?(file)
|
||||
file == "index.html"
|
||||
file.end_with? 'index.html'
|
||||
end
|
||||
|
||||
def route_for(file)
|
||||
file = file.sub("#{root}/", '')
|
||||
file = File.join(version, file) if prefix? file
|
||||
file = "" if index? file
|
||||
"/#{file}"
|
||||
end
|
||||
|
||||
def cache_control(file)
|
||||
case file
|
||||
when 'index.html' then "public, must-revalidate"
|
||||
when 'version' then "no-cache"
|
||||
case route_for(file)
|
||||
when '/' then "public, must-revalidate"
|
||||
when 'version' then "no-cache"
|
||||
else "public, max-age=#{age}"
|
||||
end
|
||||
end
|
||||
|
@ -105,8 +110,10 @@ class Travis::Web::App
|
|||
|
||||
def builder
|
||||
builder = Rack::Builder.new
|
||||
builder.use Rack::SSL if environment == 'production'
|
||||
builder.use Rack::Cache
|
||||
if environment == 'production'
|
||||
builder.use Rack::SSL
|
||||
builder.use Rack::Cache
|
||||
end
|
||||
builder.use Rack::Deflater
|
||||
builder.use Rack::Head
|
||||
builder.use Rack::ConditionalGet
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1 +1 @@
|
|||
6d938637
|
||||
d437e819
|
|
@ -1,8 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
cd "$(dirname "$0")/.."
|
||||
[ $PORT ] || PORT=9292
|
||||
[ $RACK_ENV ] || RACK_ENV=development
|
||||
|
||||
cmd="ruby -I lib -S bundle exec ruby -I lib -S unicorn -p $PORT -c ./config/unicorn.rb"
|
||||
[[ $RACK_ENV == "development" ]] && exec rerun "$cmd -o 127.0.0.1"
|
||||
exec $cmd
|
Loading…
Reference in New Issue
Block a user