Browse files

#7 - Change webserver from WEBrick to unicorn

  • Loading branch information...
1 parent ea03ad5 commit 7fa2547724843f9f555840e1b5379dfeda8e84ee @andey committed Jun 10, 2013
Showing with 38 additions and 3 deletions.
  1. +1 −1 Gemfile
  2. +7 −0 Gemfile.lock
  3. +1 −1 Procfile
  4. +1 −0 config/environments/development.rb
  5. +1 −0 config/environments/production.rb
  6. +25 −0 config/unicorn.rb
  7. +2 −1 db/schema.rb
View
2 Gemfile
@@ -5,7 +5,7 @@ ruby '2.0.0'
gem "rails", "~> 4.0.0.rc1"
gem 'pg'
#gem 'sqlite3'
-#gem 'thin'
+gem 'unicorn'
gem 'jquery-rails'
gem 'sass-rails'
gem 'coffee-rails'
View
7 Gemfile.lock
@@ -137,6 +137,7 @@ GEM
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.7.7)
+ kgio (2.8.0)
listen (0.7.3)
lumberjack (1.0.3)
mail (2.5.4)
@@ -179,6 +180,7 @@ GEM
activesupport (= 4.0.0.rc1)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
+ raindrops (0.11.0)
rake (10.0.4)
rb-inotify (0.8.8)
ffi (>= 0.5.0)
@@ -241,6 +243,10 @@ GEM
uglifier (1.3.0)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
+ unicorn (4.6.2)
+ kgio (~> 2.6)
+ rack
+ raindrops (~> 0.7)
uuidtools (2.1.4)
will_paginate (3.0.4)
xpath (2.0.0)
@@ -280,4 +286,5 @@ DEPENDENCIES
slim-rails
spork
uglifier (~> 1.3)
+ unicorn
will_paginate
View
2 Procfile
@@ -1 +1 @@
-web: bin/rails server -p $PORT -e $RAILS_ENV
+web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
View
1 config/environments/development.rb
@@ -11,6 +11,7 @@
#config.active_record.auto_explain_threshold_in_seconds = 0.5
config.assets.compress = false
config.assets.debug = true
+ config.assets.logger = false
config.log_level = :warn
config.eager_load = false
View
1 config/environments/production.rb
@@ -10,6 +10,7 @@
config.assets.compress = true
config.assets.compile = true
config.assets.digest = true
+ config.assets.logger = false
config.log_level = :error
config.action_mailer.raise_delivery_errors = false
config.i18n.fallbacks = true
View
25 config/unicorn.rb
@@ -0,0 +1,25 @@
+# config/unicorn.rb
+worker_processes 3
+timeout 30
+preload_app true
+
+before_fork do |server, worker|
+
+ Signal.trap 'TERM' do
+ puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
+ Process.kill 'QUIT', Process.pid
+ end
+
+ defined?(ActiveRecord::Base) and
+ ActiveRecord::Base.connection.disconnect!
+end
+
+after_fork do |server, worker|
+
+ Signal.trap 'TERM' do
+ puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT'
+ end
+
+ defined?(ActiveRecord::Base) and
+ ActiveRecord::Base.establish_connection
+end
View
3 db/schema.rb
@@ -113,9 +113,10 @@
add_index "trashes", ["key"], name: "index_trashes_on_key", unique: true, using: :btree
create_table "upcomings", force: true do |t|
- t.string "who"
+ t.string "title"
t.datetime "date"
t.string "description"
+ t.string "url"
t.datetime "created_at"
t.datetime "updated_at"
end

0 comments on commit 7fa2547

Please sign in to comment.