This commit is contained in:
Ilya Krasilnikov 2011-10-26 02:30:39 +04:00
parent d4e526a3d0
commit bcdc10220b
3 changed files with 22 additions and 58 deletions

View File

@ -1,36 +1,35 @@
# RVM bootstrap
$:.unshift(File.expand_path("~/.rvm/lib"))
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require 'rvm/capistrano'
set :rvm_ruby_string, 'ree@rails-3.0.5'
require 'bundler/capistrano'
require 'airbrake/capistrano'
set :rvm_type, :user
# bundler bootstrap
require 'bundler/capistrano'
# main details
ssh_options[:forward_agent] = true
set :application, "rosa_build"
set :user, "rosa_build"
default_run_options[:pty] = true
set :application, "rosa_build"
set :repository, "git@github.com:warpc/rosa-build.git"
set :branch, "master"
# set :git_shallow_clone, 1
set :scm, "git"
set :deploy_to, "/var/www/#{application}"
set :domain, "abs.rosalab.ru"
set :port, 222
set :user, "rosa"
set :domain, "195.19.76.12" # "abs.rosalab.ru"
set :port, 1822 # 222
set :use_sudo, false
set :deploy_to, "/srv/#{application}"
role :app, domain
role :web, domain
role :db, domain, :primary => true
ssh_options[:auth_methods] = %w(publickey password)
set :use_sudo, false
set :repository, "git@github.com:warpc/rosa-build.git"
set :branch, "master"
set :git_shallow_clone, 1
set :keep_releases, 3
task :symlink_config_files do
run "mkdir -p #{deploy_to}/#{shared_dir}/config"
@ -38,12 +37,11 @@ task :symlink_config_files do
run "yes y | cp -i #{release_path}/config/application.yml.sample #{deploy_to}/#{shared_dir}/config/application.yml"
run "ln -nfs #{deploy_to}/#{shared_dir}/config/database.yml #{release_path}/config/database.yml"
run "ln -nfs #{deploy_to}/#{shared_dir}/config/application.yml #{release_path}/config/application.yml"
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
run "ln -nfs #{shared_path}/config/application.yml #{release_path}/config/application.yml"
end
namespace :deploy do
desc "Restarting mod_rails with restart.txt"
task :restart, :roles => :app, :except => { :no_release => true } do
## DISABLED: run "cd #{deploy_to}/current ; ([ -f tmp/pids/unicorn.pid ] && kill -USR2 `cat tmp/pids/unicorn.pid`); true"
run ["#{current_path}/script/unicorn reload"].join("; ")
@ -57,11 +55,6 @@ namespace :deploy do
run "cd #{deploy_to}/current ; RAILS_ENV=production ./script/delayed_job stop; RAILS_ENV=production ./script/delayed_job start; true"
end
desc "Rude restart application"
task :rude_restart, :roles => :web do
run "cd #{deploy_to}/current ; pkill unicorn; sleep 0.5; pkill -9 unicorn; sleep 0.5 ; unicorn_rails -c config/unicorn.rb -E production -D "
end
# desc 'Bundle and minify the JS and CSS files'
# task :build_assets, :roles => :app do
# root_path = File.expand_path(File.dirname(__FILE__) + '/..')
@ -79,11 +72,4 @@ namespace :deploy do
# build_assets
symlink_config_files
end
after "deploy:migrate", :roles => :web do
restart
end
end
# require './config/boot'
require 'airbrake/capistrano'

View File

@ -12,7 +12,7 @@ listen '/tmp/rosa_build.sock', :backlog => 2048
timeout 120
#
#feel free to point this anywhere accessible on the filesystem
pid "/var/www/rosa_build/current/tmp/pids/unicorn.pid"
pid "/srv/rosa/rosa_build/current/tmp/pids/unicorn.pid"
#
# REE
@ -24,35 +24,13 @@ end
# By default, the Unicorn logger will write to stderr.
# Additionally, ome applications/frameworks log to stderr or stdout,
# so prevent them from going to /dev/null when daemonized here:
stderr_path "/var/www/rosa_build/shared/log/unicorn.stderr.log"
stdout_path "/var/www/rosa_build/shared/log/unicorn.stdout.log"
stderr_path "/srv/rosa/rosa_build/shared/log/unicorn.stderr.log"
stdout_path "/srv/rosa/rosa_build/shared/log/unicorn.stdout.log"
# combine REE with "preload_app true" for memory savings
# http://rubyenterpriseedition.com/faq.html#adapt_apps_for_cow
preload_app true
before_fork do |server, worker|
##
# When sent a USR2, Unicorn will suffix its pidfile with .oldbin and
# immediately start loading up a new version of itself (loaded with a new
# version of our app). When this new Unicorn is completely loaded
# it will begin spawning workers. The first worker spawned will check to
# see if an .oldbin pidfile exists. If so, this means we've just booted up
# a new Unicorn and need to tell the old one that it can now die. To do so
# we send it a QUIT.
#
# Using this method we get 0 downtime deploys.
old_pid = '/var/www/rosa_build/current/tmp/pids/unicorn.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
before_fork do |server, worker|
##
# When sent a USR2, Unicorn will suffix its pidfile with .oldbin and

View File

@ -1,10 +1,10 @@
#!/bin/sh
current_path="/var/www/rosa_build/current"
current_path="/srv/rosa/rosa_build/current"
getpid() {
pid=`ps ax |grep "unicorn_rails master -c /var/www/rosa_build" \
pid=`ps ax |grep "unicorn_rails master -c /srv/rosa/rosa_build" \
|grep -v grep \
|awk '{print $1}'`;
}