Skip to content

Commit

Permalink
Setting to get this working in production.
Browse files Browse the repository at this point in the history
  • Loading branch information
russ committed Jul 27, 2012
1 parent 5f2dd48 commit 2ab8d6d
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ gem 'sqlite3'
gem 'omniauth-twitter'
gem 'twitter'
gem 'twitter-text'
gem 'foreman'

# Gems used only for assets and not required
# in production environments by default.
Expand Down Expand Up @@ -65,4 +66,5 @@ end

group :production do
gem "mysql2"
gem "unicorn"
end
10 changes: 10 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ GEM
faraday (0.8.1)
multipart-post (~> 1.1)
ffi (1.1.0)
foreman (0.47.0)
thor (>= 0.13.6)
git-deploy (0.5.4)
net-scp
net-ssh
Expand All @@ -82,6 +84,7 @@ GEM
railties (>= 3.2.0, < 5.0)
thor (~> 0.14)
json (1.7.4)
kgio (2.7.4)
less (2.2.1)
commonjs (~> 0.2.6)
less-rails (2.2.3)
Expand Down Expand Up @@ -139,6 +142,7 @@ GEM
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
raindrops (0.10.0)
rake (0.9.2.2)
rb-fchange (0.0.5)
ffi
Expand Down Expand Up @@ -200,6 +204,10 @@ GEM
uglifier (1.2.6)
execjs (>= 0.3.0)
multi_json (~> 1.3)
unicorn (4.3.1)
kgio (~> 2.6)
rack
raindrops (~> 0.7)
xpath (0.1.4)
nokogiri (~> 1.3)

Expand All @@ -211,6 +219,7 @@ DEPENDENCIES
coffee-rails (~> 3.2.1)
database_cleaner
factory_girl_rails
foreman
git-deploy
growl
guard-rspec
Expand All @@ -228,3 +237,4 @@ DEPENDENCIES
twitter-bootstrap-rails
twitter-text
uglifier (>= 1.0.3)
unicorn
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
config.serve_static_assets = false

# Compress JavaScripts and CSS
config.assets.compress = true
config.assets.compress = false

# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = false
Expand Down
19 changes: 19 additions & 0 deletions config/unicorn.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
worker_processes 3
timeout 30
preload_app true

before_fork do |server, worker|
if defined?(ActiveRecord::Base)
ActiveRecord::Base.connection.disconnect!
Rails.logger.info("Disconnected from ActiveRecord")
end

sleep 1
end

after_fork do |server, worker|
if defined?(ActiveRecord::Base)
ActiveRecord::Base.establish_connection
Rails.logger.info("Connected to ActiveRecord")
end
end
2 changes: 2 additions & 0 deletions deploy/before_restart
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ if File.file? 'Rakefile'
run "#{rake_cmd} #{tasks.join(' ')} RAILS_ENV=#{RAILS_ENV}" if tasks.any?
end

run 'bundle exec rake assets:precompile'

# clear cached assets (unversioned/ignored files)
run "git clean -x -f -- public/stylesheets public/javascripts"

Expand Down
5 changes: 3 additions & 2 deletions deploy/restart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/sh
touch tmp/restart.txt
echo "restarting Passenger app"
sudo /usr/sbin/service lvrug stop
sudo /usr/sbin/service lvrug start
echo "restarting app"

0 comments on commit 2ab8d6d

Please sign in to comment.