Skip to content

Commit

Permalink
Use simple deployment strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
scottwillson committed Feb 6, 2012
1 parent 55a1b9c commit fa072c1
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 31 deletions.
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -23,6 +23,7 @@ gem "truncate_html"

group :development do
gem "capistrano"
gem "capistrano-unicorn"
end

group :test do
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Expand Up @@ -76,6 +76,8 @@ GEM
net-sftp (>= 2.0.0)
net-ssh (>= 2.0.14)
net-ssh-gateway (>= 1.1.0)
capistrano-unicorn (0.1.5)
capistrano
capybara (1.1.2)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
Expand Down Expand Up @@ -184,6 +186,7 @@ DEPENDENCIES
ansi
authlogic
capistrano
capistrano-unicorn
capybara
database_cleaner
erubis
Expand Down
20 changes: 3 additions & 17 deletions config/deploy.rb
@@ -1,5 +1,7 @@
load "config/db"
load "local/config/deploy.rb" if File.exists?("local/config/deploy.rb")
require 'bundler/capistrano'
require "capistrano-unicorn"

set :scm, "git"
set :repository, "git://github.com/scottwillson/racing_on_rails.git"
Expand All @@ -9,7 +11,7 @@
set :deploy_via, :remote_cache
set :keep_releases, 5

set :deploy_to, "/usr/local/www/rails/#{application}"
set :deploy_to, "/var/www/rails/#{application}"

set :user, "app"
set :use_sudo, false
Expand Down Expand Up @@ -41,22 +43,6 @@
run("if [ -e \"#{previous_release}/public/#{cached_path}\" ]; then cp -pr #{previous_release}/public/#{cached_path} #{release_path}/public/#{cached_path}; fi") rescue nil
end
end

task :start, :roles => :app do
run "/usr/local/etc/rc.d/unicorn start #{application}"
end

task :stop, :roles => :app do
run "/usr/local/etc/rc.d/unicorn stop #{application}"
end

task :restart, :roles => :app do
run "/usr/local/etc/rc.d/unicorn reload #{application}"
end

task :status, :roles => :app do
run "/usr/local/etc/rc.d/unicorn status #{application}"
end

namespace :web do
desc "Present a maintenance page to visitors"
Expand Down
11 changes: 11 additions & 0 deletions config/new_server.rb
@@ -0,0 +1,11 @@
load "deploy"
load "config/deploy"
require "capistrano-unicorn"

roles.clear
role :app, "bushtit.obra.org"
role :db, "bushtit.obra.org", :primary => true
set :user, "app"

set :rails_env, "production"
set :deploy_to, "/var/www/rails/#{application}"
13 changes: 0 additions & 13 deletions config/unicorn.rb

This file was deleted.

32 changes: 32 additions & 0 deletions config/unicorn/production.rb
@@ -0,0 +1,32 @@
rails_env = ENV['::Rails.env'] || 'production'

worker_processes 4
preload_app true
timeout 180

user 'app', 'app'

app_path = File.expand_path(File.dirname(__FILE__) + "/../../../current")
working_directory app_path
listen "#{app_path}/tmp/sockets/unicorn.sock", :backlog => 64
stderr_path "log/unicorn.stderr.log"
stdout_path "log/unicorn.stdout.log"

pid "#{app_path}/tmp/pids/unicorn.pid"

before_fork do |server, worker|
ActiveRecord::Base.connection.disconnect!

old_pid = "#{server.config[:pid]}.oldbin"
if File.exists?(old_pid) && server.pid != old_pid
begin
Process.kill("QUIT", File.read(old_pid).to_i)
rescue Errno::ENOENT, Errno::ESRCH
# someone else did our job for us
end
end
end

after_fork do |server, worker|
ActiveRecord::Base.establish_connection
end
1 change: 0 additions & 1 deletion config/unicorn_development.rb

This file was deleted.

0 comments on commit fa072c1

Please sign in to comment.