From 86d24244384e5e071782d07a6f361c0a7d0ae7d0 Mon Sep 17 00:00:00 2001 From: Francis Gulotta Date: Mon, 3 Mar 2014 13:37:09 -0500 Subject: [PATCH] Add a .env sample for a local foreman, add a unicorn config, and upgrade rails to 4.0.3 --- .gitignore | 1 + Gemfile | 8 ++-- Gemfile.lock | 99 ++++++++++++++++++++++------------------------- config/unicorn.rb | 25 ++++++++++++ env.sample | 2 + 5 files changed, 78 insertions(+), 57 deletions(-) create mode 100644 config/unicorn.rb create mode 100644 env.sample diff --git a/.gitignore b/.gitignore index 4c22346..9004248 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ /tmp .ruby-version .DS_Store +.env diff --git a/Gemfile b/Gemfile index 75e80bf..c60060a 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source 'https://rubygems.org' ruby "2.0.0" -gem 'rails', '4.0.0' +gem 'rails', '4.0.3' group :development do gem "pry-rails" @@ -13,11 +13,11 @@ group :production do gem 'rails_12factor' end -gem 'sass-rails', '~> 4.0.0' -gem 'bootstrap-sass', github: 'thomas-mcdonald/bootstrap-sass', branch: '3' +gem 'sass-rails' +gem 'bootstrap-sass' gem "font-awesome-rails" gem 'uglifier', '>= 1.3.0' -gem 'coffee-rails', '~> 4.0.0' +gem 'coffee-rails' gem 'jquery-rails' gem 'turbolinks' gem 'jbuilder', '~> 1.2' diff --git a/Gemfile.lock b/Gemfile.lock index fd3f9ca..6bb012a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,11 +1,3 @@ -GIT - remote: git://github.com/thomas-mcdonald/bootstrap-sass.git - revision: f4294bfd0218a181a3c288dba7cb9811a99b9f83 - branch: 3 - specs: - bootstrap-sass (3.0.0.0) - sass (~> 3.2) - GIT remote: https://github.com/mongoid/mongoid.git revision: 5d8397e24b673724f4b70ca2923a62bfe20e6e79 @@ -19,57 +11,58 @@ GIT GEM remote: https://rubygems.org/ specs: - actionmailer (4.0.0) - actionpack (= 4.0.0) - mail (~> 2.5.3) - actionpack (4.0.0) - activesupport (= 4.0.0) + actionmailer (4.0.3) + actionpack (= 4.0.3) + mail (~> 2.5.4) + actionpack (4.0.3) + activesupport (= 4.0.3) builder (~> 3.1.0) erubis (~> 2.7.0) rack (~> 1.5.2) rack-test (~> 0.6.2) - activemodel (4.0.0) - activesupport (= 4.0.0) + activemodel (4.0.3) + activesupport (= 4.0.3) builder (~> 3.1.0) - activerecord (4.0.0) - activemodel (= 4.0.0) + activerecord (4.0.3) + activemodel (= 4.0.3) activerecord-deprecated_finders (~> 1.0.2) - activesupport (= 4.0.0) + activesupport (= 4.0.3) arel (~> 4.0.0) activerecord-deprecated_finders (1.0.3) - activesupport (4.0.0) + activesupport (4.0.3) i18n (~> 0.6, >= 0.6.4) minitest (~> 4.2) multi_json (~> 1.3) thread_safe (~> 0.1) tzinfo (~> 0.3.37) - arel (4.0.0) - atomic (1.1.10) + arel (4.0.2) + atomic (1.1.15) better_errors (0.9.0) coderay (>= 1.0.0) erubis (>= 2.6.6) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) + bootstrap-sass (3.1.1.0) + sass (~> 3.2) builder (3.1.4) coderay (1.0.9) - coffee-rails (4.0.0) + coffee-rails (4.0.1) coffee-script (>= 2.2.0) - railties (>= 4.0.0.beta, < 5.0) + railties (>= 4.0.0, < 5.0) coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.6.3) + coffee-script-source (1.7.0) debug_inspector (0.0.2) erubis (2.7.0) - execjs (1.4.0) - multi_json (~> 1.0) + execjs (2.0.2) figaro (0.6.4) bundler (~> 1.0) rails (>= 3, < 5) font-awesome-rails (3.2.1.2) railties (>= 3.2, < 5.0) hike (1.2.3) - i18n (0.6.4) + i18n (0.6.9) jbuilder (1.4.2) activesupport (>= 3.0.0) multi_json (>= 1.2.0) @@ -81,12 +74,12 @@ GEM mime-types (~> 1.16) treetop (~> 1.4.8) method_source (0.8.2) - mime-types (1.23) + mime-types (1.25.1) minitest (4.7.5) moped (1.5.0) - multi_json (1.7.7) + multi_json (1.8.4) origin (1.1.0) - polyglot (0.3.3) + polyglot (0.3.4) pry (0.9.12.4) coderay (~> 1.0) method_source (~> 0.8) @@ -96,51 +89,51 @@ GEM rack (1.5.2) rack-test (0.6.2) rack (>= 1.0) - rails (4.0.0) - actionmailer (= 4.0.0) - actionpack (= 4.0.0) - activerecord (= 4.0.0) - activesupport (= 4.0.0) + rails (4.0.3) + actionmailer (= 4.0.3) + actionpack (= 4.0.3) + activerecord (= 4.0.3) + activesupport (= 4.0.3) bundler (>= 1.3.0, < 2.0) - railties (= 4.0.0) + railties (= 4.0.3) sprockets-rails (~> 2.0.0) rails_12factor (0.0.2) rails_serve_static_assets rails_stdout_logging rails_serve_static_assets (0.0.1) rails_stdout_logging (0.0.1) - railties (4.0.0) - actionpack (= 4.0.0) - activesupport (= 4.0.0) + railties (4.0.3) + actionpack (= 4.0.3) + activesupport (= 4.0.3) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) raindrops (0.11.0) - rake (10.1.0) - sass (3.2.9) - sass-rails (4.0.0) - railties (>= 4.0.0.beta, < 5.0) + rake (10.1.1) + sass (3.2.14) + sass-rails (4.0.1) + railties (>= 4.0.0, < 5.0) sass (>= 3.1.10) sprockets-rails (~> 2.0.0) slop (3.4.7) - sprockets (2.10.0) + sprockets (2.11.0) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sprockets-rails (2.0.0) + sprockets-rails (2.0.1) actionpack (>= 3.0) activesupport (>= 3.0) sprockets (~> 2.8) thor (0.18.1) - thread_safe (0.1.0) - atomic + thread_safe (0.2.0) + atomic (>= 1.1.7, < 2) tilt (1.4.1) - treetop (1.4.14) + treetop (1.4.15) polyglot polyglot (>= 0.3.1) turbolinks (1.3.0) coffee-rails - tzinfo (0.3.37) + tzinfo (0.3.38) uglifier (2.1.2) execjs (>= 0.3.0) multi_json (~> 1.0, >= 1.0.2) @@ -158,17 +151,17 @@ PLATFORMS DEPENDENCIES better_errors binding_of_caller - bootstrap-sass! - coffee-rails (~> 4.0.0) + bootstrap-sass + coffee-rails figaro font-awesome-rails jbuilder (~> 1.2) jquery-rails mongoid! pry-rails - rails (= 4.0.0) + rails (= 4.0.3) rails_12factor - sass-rails (~> 4.0.0) + sass-rails turbolinks uglifier (>= 1.3.0) unicorn diff --git a/config/unicorn.rb b/config/unicorn.rb new file mode 100644 index 0000000..84f27d8 --- /dev/null +++ b/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 diff --git a/env.sample b/env.sample new file mode 100644 index 0000000..ef099b6 --- /dev/null +++ b/env.sample @@ -0,0 +1,2 @@ +PORT=3000 +RACK_ENV=DEVELOPMENT \ No newline at end of file