Created
October 31, 2011 14:54
-
-
Save psy-q/1327661 to your computer and use it in GitHub Desktop.
Capistrano bundler integration using the wrong release for installing bundle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[rca@lala leihs]$ cap staging deploy | |
* executing `staging' | |
triggering start callbacks for `deploy' | |
* executing `multistage:ensure' | |
* executing `deploy' | |
triggering before callbacks for `deploy' | |
* executing `retrieve_db_config' | |
servers: ["rails.zhdk.ch"] | |
** sftp download /home/leihs/leihs-test/database.yml -> /tmp/leihs_db_config.yml | |
[rails.zhdk.ch] /home/leihs/leihs-test/database.yml | |
[rails.zhdk.ch] done | |
* sftp download complete | |
* executing `stop_sphinx' | |
* executing "ls -x /home/leihs/leihs-test/releases" | |
servers: ["rails.zhdk.ch"] | |
[leihs@rails.zhdk.ch] executing command | |
command finished in 157ms | |
* executing "cd /home/leihs/leihs-test/releases/20111018115402 && RAILS_ENV='production' bundle exec rake ts:stop" | |
servers: ["rails.zhdk.ch"] | |
[leihs@rails.zhdk.ch] executing command | |
*** [err :: leihs@rails.zhdk.ch] /usr/local/rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.20/lib/bundler/runtime.rb:136: warning: Insecure world writable dir /home in PATH, mode 040777 | |
*** [err :: leihs@rails.zhdk.ch] /home/leihs/leihs-test/shared/bundle/ruby/1.9.1/gems/rack-1.3.4/lib/rack/backports/uri/common_192.rb:53: warning: already initialized constant WFKV_ | |
** [out :: leihs@rails.zhdk.ch] searchd is not running | |
command finished in 21660ms | |
* executing `deploy:update' | |
** transaction: start | |
* executing `deploy:update_code' | |
updating the cached checkout on all servers | |
executing locally: "git ls-remote git://github.com/psy-q/leihs.git Rails3.1" | |
command finished in 305ms | |
* executing "if [ -d /home/leihs/leihs-test/shared/cached-copy ]; then cd /home/leihs/leihs-test/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 3c28c96b3de4e248101e0b74d80da231c025b213 && git clean -q -d -x -f; else git clone -q git://github.com/psy-q/leihs.git /home/leihs/leihs-test/shared/cached-copy && cd /home/leihs/leihs-test/shared/cached-copy && git checkout -q -b deploy 3c28c96b3de4e248101e0b74d80da231c025b213; fi" | |
servers: ["rails.zhdk.ch"] | |
[leihs@rails.zhdk.ch] executing command | |
command finished in 1565ms | |
copying the cached version to /home/leihs/leihs-test/releases/20111031145108 | |
* executing "cp -RPp /home/leihs/leihs-test/shared/cached-copy /home/leihs/leihs-test/releases/20111031145108 && (echo 3c28c96b3de4e248101e0b74d80da231c025b213 > /home/leihs/leihs-test/releases/20111031145108/REVISION)" | |
servers: ["rails.zhdk.ch"] | |
[leihs@rails.zhdk.ch] executing command | |
command finished in 6845ms | |
* executing `deploy:finalize_update' | |
* executing "chmod -R g+w /home/leihs/leihs-test/releases/20111031145108" | |
servers: ["rails.zhdk.ch"] | |
[leihs@rails.zhdk.ch] executing command | |
command finished in 1621ms | |
* executing "rm -rf /home/leihs/leihs-test/releases/20111031145108/log /home/leihs/leihs-test/releases/20111031145108/public/system /home/leihs/leihs-test/releases/20111031145108/tmp/pids &&\\\n mkdir -p /home/leihs/leihs-test/releases/20111031145108/public &&\\\n mkdir -p /home/leihs/leihs-test/releases/20111031145108/tmp &&\\\n ln -s /home/leihs/leihs-test/shared/log /home/leihs/leihs-test/releases/20111031145108/log &&\\\n ln -s /home/leihs/leihs-test/shared/system /home/leihs/leihs-test/releases/20111031145108/public/system &&\\\n ln -s /home/leihs/leihs-test/shared/pids /home/leihs/leihs-test/releases/20111031145108/tmp/pids" | |
servers: ["rails.zhdk.ch"] | |
[leihs@rails.zhdk.ch] executing command | |
command finished in 164ms | |
* executing "find /home/leihs/leihs-test/releases/20111031145108/public/images /home/leihs/leihs-test/releases/20111031145108/public/stylesheets /home/leihs/leihs-test/releases/20111031145108/public/javascripts -exec touch -t 201110311451.17 {} ';'; true" | |
servers: ["rails.zhdk.ch"] | |
[leihs@rails.zhdk.ch] executing command | |
command finished in 476ms | |
triggering after callbacks for `deploy:finalize_update' | |
* executing `bundle:install' | |
triggering before callbacks for `bundle:install' | |
* executing `deploy:symlink' | |
* executing "rm -f /home/leihs/leihs-test/current && ln -s /home/leihs/leihs-test/releases/20111031145108 /home/leihs/leihs-test/current" | |
servers: ["rails.zhdk.ch"] | |
[leihs@rails.zhdk.ch] executing command | |
command finished in 156ms | |
triggering after callbacks for `deploy:symlink' | |
* executing `link_config' | |
* executing "rm -f /home/leihs/leihs-test/releases/20111031145108/config/database.yml" | |
servers: ["rails.zhdk.ch"] | |
[leihs@rails.zhdk.ch] executing command | |
command finished in 154ms | |
* executing "rm -f /home/leihs/leihs-test/releases/20111031145108/config/application.rb" | |
servers: ["rails.zhdk.ch"] | |
[leihs@rails.zhdk.ch] executing command | |
command finished in 156ms | |
* executing "ln -s /home/leihs/leihs-test/database.yml /home/leihs/leihs-test/releases/20111031145108/config/database.yml" | |
servers: ["rails.zhdk.ch"] | |
[leihs@rails.zhdk.ch] executing command | |
command finished in 156ms | |
* executing "ln -s /home/leihs/leihs-test/application.rb /home/leihs/leihs-test/releases/20111031145108/config/application.rb" | |
servers: ["rails.zhdk.ch"] | |
[leihs@rails.zhdk.ch] executing command | |
command finished in 156ms | |
* executing `link_attachments' | |
* executing "rm -rf /home/leihs/leihs-test/releases/20111031145108/public/images/attachments" | |
servers: ["rails.zhdk.ch"] | |
[leihs@rails.zhdk.ch] executing command | |
command finished in 154ms | |
* executing "ln -s /home/leihs/leihs-test/shared/attachments /home/leihs/leihs-test/releases/20111031145108/public/images/attachments" | |
servers: ["rails.zhdk.ch"] | |
[leihs@rails.zhdk.ch] executing command | |
command finished in 153ms | |
* executing "rm -rf /home/leihs/leihs-test/releases/20111031145108/public/attachments" | |
servers: ["rails.zhdk.ch"] | |
[leihs@rails.zhdk.ch] executing command | |
command finished in 155ms | |
* executing "ln -s /home/leihs/leihs-test/shared/attachments /home/leihs/leihs-test/releases/20111031145108/public/attachments" | |
servers: ["rails.zhdk.ch"] | |
[leihs@rails.zhdk.ch] executing command | |
command finished in 156ms | |
* executing `link_db_backups' | |
* executing "rm -rf /home/leihs/leihs-test/releases/20111031145108/db/backups" | |
servers: ["rails.zhdk.ch"] | |
[leihs@rails.zhdk.ch] executing command | |
command finished in 153ms | |
* executing "ln -s /home/leihs/leihs-test/shared/db_backups /home/leihs/leihs-test/releases/20111031145108/db/backups" | |
servers: ["rails.zhdk.ch"] | |
[leihs@rails.zhdk.ch] executing command | |
command finished in 157ms | |
* executing `chmod_tmp' | |
* executing "chmod g-w /home/leihs/leihs-test/releases/20111031145108/tmp" | |
servers: ["rails.zhdk.ch"] | |
[leihs@rails.zhdk.ch] executing command | |
command finished in 156ms | |
* executing "cd /home/leihs/leihs-test/releases/20111018143710 && bundle install --gemfile /home/leihs/leihs-test/releases/20111018143710/Gemfile --path /home/leihs/leihs-test/shared/bundle --deployment --quiet --without development test" | |
servers: ["rails.zhdk.ch"] | |
[leihs@rails.zhdk.ch] executing command | |
command finished in 866ms | |
triggering after callbacks for `bundle:install' | |
* executing `backup_database' | |
* executing "mysqldump -h db.zhdk.ch --user=leihs2dev --password=mxCqnnYKN5T3jnyD -r /home/leihs/leihs-test/shared/db_backups/rails_leihs2_dev-2011-10-31T15-51-20+01-00.sql rails_leihs2_dev" | |
servers: ["rails.zhdk.ch"] | |
[leihs@rails.zhdk.ch] executing command | |
command finished in 1721ms | |
* executing "bzip2 /home/leihs/leihs-test/shared/db_backups/rails_leihs2_dev-2011-10-31T15-51-20+01-00.sql" | |
servers: ["rails.zhdk.ch"] | |
[leihs@rails.zhdk.ch] executing command | |
command finished in 6730ms | |
triggering after callbacks for `backup_database' | |
* executing `deploy:migrate' | |
* executing `configure_sphinx' | |
* executing "cd /home/leihs/leihs-test/releases/20111031145108 && RAILS_ENV='production' bundle exec rake ts:config" | |
servers: ["rails.zhdk.ch"] | |
[leihs@rails.zhdk.ch] executing command | |
** [out :: leihs@rails.zhdk.ch] Could not find gem 'haml_assets (>= 0) ruby' in any of the gem sources listed in your Gemfile. | |
command finished in 592ms | |
*** [deploy:symlink] rolling back | |
* executing "rm -f /home/leihs/leihs-test/current; ln -s /home/leihs/leihs-test/releases/20111018115402 /home/leihs/leihs-test/current; true" | |
servers: ["rails.zhdk.ch"] | |
[leihs@rails.zhdk.ch] executing command | |
command finished in 160ms | |
*** [deploy:update_code] rolling back | |
* executing "rm -rf /home/leihs/leihs-test/releases/20111031145108; true" | |
servers: ["rails.zhdk.ch"] | |
[leihs@rails.zhdk.ch] executing command | |
command finished in 1173ms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path. | |
require "rvm/capistrano" # Load RVM's capistrano plugin. | |
set :rvm_ruby_string, '1.9.2' # Or whatever env you want it to run in. | |
require "bundler/capistrano" | |
set :application, "leihs-test" | |
set :scm, :git | |
set :repository, "git://github.com/psy-q/leihs.git" | |
set :branch, "Rails3.1" | |
set :deploy_via, :remote_cache | |
set :db_config, "/home/leihs/#{application}/database.yml" | |
set :app_config, "/home/leihs/#{application}/application.rb" | |
set :ldap_config, "/home/leihs/#{application}/LDAP.yml" | |
set :use_sudo, false | |
set :rails_env, "production" | |
default_run_options[:shell] = false | |
set :deploy_to, "/home/leihs/#{application}" | |
role :app, "leihs@rails.zhdk.ch" | |
role :web, "leihs@rails.zhdk.ch" | |
role :db, "leihs@rails.zhdk.ch", :primary => true | |
task :retrieve_db_config do | |
# DB credentials needed by Sphinx, mysqldump etc. | |
get(db_config, "/tmp/leihs_db_config.yml") | |
dbconf = YAML::load_file("/tmp/leihs_db_config.yml")["production"] | |
set :sql_database, dbconf['database'] | |
set :sql_host, dbconf['host'] | |
set :sql_username, dbconf['username'] | |
set :sql_password, dbconf['password'] | |
end | |
task :link_config do | |
if File.exist?("#{release_path}/config/LDAP.yml") | |
run "rm #{release_path}/config/LDAP.yml" | |
run "ln -s #{ldap_config} #{release_path}/config/LDAP.yml" | |
end | |
run "rm -f #{release_path}/config/database.yml" | |
run "rm -f #{release_path}/config/application.rb" | |
run "ln -s #{db_config} #{release_path}/config/database.yml" | |
run "ln -s #{app_config} #{release_path}/config/application.rb" | |
end | |
task :link_attachments do | |
run "rm -rf #{release_path}/public/images/attachments" | |
run "ln -s #{deploy_to}/#{shared_dir}/attachments #{release_path}/public/images/attachments" | |
run "rm -rf #{release_path}/public/attachments" | |
run "ln -s #{deploy_to}/#{shared_dir}/attachments #{release_path}/public/attachments" | |
end | |
task :link_db_backups do | |
run "rm -rf #{release_path}/db/backups" | |
run "ln -s #{deploy_to}/#{shared_dir}/db_backups #{release_path}/db/backups" | |
end | |
task :link_sphinx do | |
run "rm -rf #{release_path}/db/sphinx" | |
run "ln -s #{deploy_to}/#{shared_dir}/sphinx #{release_path}/db/sphinx" | |
end | |
task :make_tmp do | |
run "mkdir -p #{release_path}/tmp/sessions #{release_path}/tmp/cache" | |
end | |
task :chmod_tmp do | |
run "chmod g-w #{release_path}/tmp" | |
end | |
task :configure_sphinx do | |
run "cd #{release_path} && RAILS_ENV='production' bundle exec rake ts:config" | |
run "sed -i 's/listen = 127.0.0.1:3342/listen = 127.0.0.1:3352/' #{release_path}/config/production.sphinx.conf" | |
run "sed -i 's/listen = 127.0.0.1:3343/listen = 127.0.0.1:3353/' #{release_path}/config/production.sphinx.conf" | |
run "sed -i 's/listen = 127.0.0.1:3344/listen = 127.0.0.1:3354/' #{release_path}/config/production.sphinx.conf" | |
run "sed -i 's/sql_host =.*/sql_host = #{sql_host}/' #{release_path}/config/production.sphinx.conf" | |
run "sed -i 's/sql_user =.*/sql_user = #{sql_username}/' #{release_path}/config/production.sphinx.conf" | |
run "sed -i 's/sql_pass =.*/sql_pass = #{sql_password}/' #{release_path}/config/production.sphinx.conf" | |
run "sed -i 's/sql_db =.*/sql_db = #{sql_database}/' #{release_path}/config/production.sphinx.conf" | |
run "sed -i 's/sql_sock.*//' #{release_path}/config/production.sphinx.conf" | |
run "sed -i 's/port: 3342/port: 3352/' #{release_path}/config/sphinx.yml" | |
run "sed -i 's/port: 3343/port: 3353/' #{release_path}/config/sphinx.yml" | |
run "sed -i 's/port: 3344/port: 3354/' #{release_path}/config/sphinx.yml" | |
end | |
task :stop_sphinx do | |
run "cd #{previous_release} && RAILS_ENV='production' bundle exec rake ts:stop" | |
end | |
task :start_sphinx do | |
run "cd #{release_path} && RAILS_ENV='production' bundle exec rake ts:reindex" | |
run "cd #{release_path} && RAILS_ENV='production' bundle exec rake ts:start" | |
end | |
task :backup_database do | |
# Produce a string like 2010-07-15T09-16-35+02-00 | |
date_string = DateTime.now.to_s.gsub(":","-") | |
dump_dir = "#{deploy_to}/#{shared_dir}/db_backups" | |
dump_path = "#{dump_dir}/#{sql_database}-#{date_string}.sql" | |
# If mysqldump fails for any reason, Capistrano will stop here | |
# because run catches the exit code of mysqldump | |
run "mysqldump -h #{sql_host} --user=#{sql_username} --password=#{sql_password} -r #{dump_path} #{sql_database}" | |
run "bzip2 #{dump_path}" | |
end | |
namespace :deploy do | |
task :start do | |
# we do absolutely nothing here, as we currently aren't | |
# using a spinner script or anything of that sort. | |
end | |
task :restart, :roles => :app, :except => { :no_release => true } do | |
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}" | |
end | |
# This overwrites the (broken, when using Bundler) deploy:migrate task | |
task :migrate do | |
end | |
end | |
before "deploy", "retrieve_db_config" | |
before "deploy:cold", "retrieve_db_config" | |
before "deploy", :stop_sphinx | |
before "bundle:install", "deploy:symlink" | |
after "deploy:symlink", :link_config | |
after "deploy:symlink", :link_attachments | |
after "deploy:symlink", :link_db_backups | |
after "deploy:symlink", :chmod_tmp | |
after "bundle:install", :backup_database | |
after "backup_database", "deploy:migrate" | |
after "backup_database", :configure_sphinx | |
before "deploy:restart", :make_tmp | |
before "start_sphinx", :link_sphinx | |
after "deploy", :start_sphinx | |
after "deploy:cold", :start_sphinx | |
after "deploy", "deploy:cleanup" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment