setting deploy, not yet finished configs
This commit is contained in:
parent
3b51d53225
commit
7a608488cd
2
Capfile
2
Capfile
|
@ -1,4 +1,4 @@
|
|||
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
|
||||
Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
|
||||
Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
|
||||
|
||||
load 'config/deploy' # remove this line to skip loading any of the default tasks
|
105
config/deploy.rb
105
config/deploy.rb
|
@ -1,24 +1,93 @@
|
|||
set :application, "set your application name here"
|
||||
set :repository, "set your repository location here"
|
||||
# RVM bootstrap
|
||||
$:.unshift(File.expand_path("~/.rvm/lib"))
|
||||
require 'rvm/capistrano'
|
||||
set :rvm_ruby_string, 'ree@rails-3.0.5'
|
||||
set :rvm_type, :user
|
||||
|
||||
set :scm, :subversion
|
||||
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
|
||||
# bundler bootstrap
|
||||
require 'bundler/capistrano'
|
||||
|
||||
role :web, "your web-server here" # Your HTTP server, Apache/etc
|
||||
role :app, "your app-server here" # This may be the same as your `Web` server
|
||||
role :db, "your primary db-server here", :primary => true # This is where Rails migrations will run
|
||||
role :db, "your slave db-server here"
|
||||
# main details
|
||||
set :application, "rosa_build"
|
||||
set :user, "rosa_build"
|
||||
|
||||
# If you are using Passenger mod_rails uncomment this:
|
||||
# if you're still using the script/reapear helper you will need
|
||||
# these http://github.com/rails/irs_process_scripts
|
||||
default_run_options[:pty] = true
|
||||
set :scm, "git"
|
||||
|
||||
# namespace :deploy do
|
||||
# task :start do ; end
|
||||
# task :stop do ; end
|
||||
# task :restart, :roles => :app, :except => { :no_release => true } do
|
||||
# run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
|
||||
set :deploy_to, "/var/www/#{application}"
|
||||
|
||||
set :domain, "abs.rosalab.ru"
|
||||
set :port, 222
|
||||
|
||||
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:evilmartians/rosa-build.git"
|
||||
set :branch, "master"
|
||||
set :git_shallow_clone, 1
|
||||
set :keep_releases, 3
|
||||
|
||||
after "deploy:update_code", :symlink_config_files
|
||||
|
||||
#before "deploy:update_code", "delayed_job:stop"
|
||||
#after "deploy:symlink", "delayed_job:start"
|
||||
|
||||
#before "deploy:restart", :symlink_and_rebuild_sphinx
|
||||
|
||||
task :symlink_config_files do
|
||||
run "mkdir -p #{deploy_to}/#{shared_dir}/config"
|
||||
|
||||
run "yes n | cp -i #{release_path}/config/database.yml.sample #{deploy_to}/#{shared_dir}/config/database.yml"
|
||||
run "yes n | cp -i #{release_path}/config/config.yml.sample #{deploy_to}/#{shared_dir}/config/config.yml"
|
||||
|
||||
run "ln -nfs #{deploy_to}/#{shared_dir}/config/database.yml #{release_path}/config/database.yml"
|
||||
run "ln -nfs #{deploy_to}/#{shared_dir}/config/config.yml #{release_path}/config/config.yml"
|
||||
end
|
||||
|
||||
namespace :deploy do
|
||||
desc "Restarting mod_rails with restart.txt"
|
||||
task :restart, :roles => :app, :except => { :no_release => true } do
|
||||
run "cd #{deploy_to}/current ; ([ -f tmp/pids/unicorn.pid ] && kill -USR2 `cat tmp/pids/unicorn.pid`); true"
|
||||
# run "touch #{current_path}/tmp/restart.txt"
|
||||
# run "kill -USR2 `cat /var/www/musicus/shared/pids/unicorn.pid` || true"
|
||||
end
|
||||
|
||||
%w(start).each { |name| task name, :roles => :app do deploy.restart end }
|
||||
end
|
||||
|
||||
#namespace :delayed_job do
|
||||
# desc "Start delayed_job process"
|
||||
# task :start, :roles => :app do
|
||||
# run "cd #{current_path}; RAILS_ENV=production script/delayed_job start"
|
||||
# end
|
||||
#
|
||||
# desc "Stop delayed_job process"
|
||||
# task :stop, :roles => :app do
|
||||
# run "[ -d #{current_path} ] && cd #{current_path} && RAILS_ENV=production script/delayed_job stop || true"
|
||||
# end
|
||||
#
|
||||
# desc "Restart delayed_job process"
|
||||
# task :restart, :roles => :app do
|
||||
# run "cd #{current_path}; RAILS_ENV=production script/delayed_job restart"
|
||||
# end
|
||||
#end
|
||||
require 'config/boot'
|
||||
require 'hoptoad_notifier/capistrano'
|
||||
|
||||
#task :symlink_and_rebuild_sphinx, :roles => [:app] do
|
||||
# thinking_sphinx.stop
|
||||
# symlink_sphinx_indexes
|
||||
# thinking_sphinx.rebuild
|
||||
#end
|
||||
|
||||
#task :symlink_sphinx_indexes, :roles => [:app] do
|
||||
# run "ln -nfs #{shared_path}/db/sphinx #{release_path}/db/sphinx"
|
||||
#end
|
||||
|
||||
# TODO: How to setup it in rails3
|
||||
#Dir[File.join(File.dirname(__FILE__), '..', 'vendor', 'gems', 'hoptoad_notifier-*')].each do |vendored_notifier|
|
||||
# $: << File.join(vendored_notifier, 'lib')
|
||||
#end
|
||||
#
|
||||
#require 'hoptoad_notifier/capistrano'
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
#rails_env = ENV['RAILS_ENV'] || 'production'
|
||||
worker_processes 4
|
||||
|
||||
preload_app true
|
||||
|
||||
#working_directory "/path/to/app/current" # available in 0.94.0+
|
||||
listen '/tmp/rosa_build.sock', :backlog => 2048
|
||||
#listen "/tmp/.sock", :backlog => 64
|
||||
#listen 8080, :tcp_nopush => true
|
||||
#
|
||||
#nuke workers after 30 seconds instead of 60 seconds (the default)
|
||||
timeout 120
|
||||
#
|
||||
#feel free to point this anywhere accessible on the filesystem
|
||||
#pid "/path/to/app/shared/pids/unicorn.pid"
|
||||
|
||||
#
|
||||
# REE
|
||||
# http://www.rubyenterpriseedition.com/faq.html#adapt_apps_for_cow
|
||||
if GC.respond_to?(:copy_on_write_friendly=)
|
||||
GC.copy_on_write_friendly = true
|
||||
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 "/war/www/rosa_build/shared/log/unicorn.stderr.log"
|
||||
stdout_path "/war/www/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 = Rails.root + '/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|
|
||||
# # the following is highly recomended for Rails + "preload_app true"
|
||||
# # as there's no need for the master process to hold a connection
|
||||
# defined?(ActiveRecord::Base) and
|
||||
# ActiveRecord::Base.connection.disconnect!
|
||||
#end
|
||||
|
||||
after_fork do |server, worker|
|
||||
# per-process listener ports for debugging/admin/migrations
|
||||
# addr = "127.0.0.1:#{9293 + worker.nr}"
|
||||
# server.listen(addr, :tries => -1, :delay => 5, :tcp_nopush => true)
|
||||
|
||||
# the following is *required* for Rails + "preload_app true",
|
||||
defined?(ActiveRecord::Base) and
|
||||
ActiveRecord::Base.establish_connection
|
||||
|
||||
# if preload_app is true, then you may also want to check and
|
||||
# restart any other shared sockets/descriptors such as Memcached,
|
||||
# and Redis. TokyoCabinet file handles are safe to reuse
|
||||
# between any number of forked children (assuming your kernel
|
||||
# correctly implements pread()/pwrite() system calls)
|
||||
srand
|
||||
end
|
Loading…
Reference in New Issue