Skip to content

Instantly share code, notes, and snippets.

@localshred
Created February 4, 2010 22:45
Show Gist options
  • Save localshred/295222 to your computer and use it in GitHub Desktop.
Save localshred/295222 to your computer and use it in GitHub Desktop.
$ cap deploy:cold
* executing `deploy:cold'
* executing `deploy:update'
** transaction: start
* executing `deploy:update_code'
executing locally: "git ls-remote [email protected]:/home/git/myapp.git HEAD"
* executing "git clone -q [email protected]:/home/git/myapp.git /var/www/myapp/releases/20100204223421 && cd /var/www/myapp/releases/20100204223421 && git checkout -q -b deploy 14dd2843341cd0984afb147050a02228ee7eae02 && (echo 14dd2843341cd0984afb147050a02228ee7eae02 > /var/www/myapp/releases/20100204223421/REVISION)"
servers: ["mydomain.com"]
[mydomain.com] executing command
command finished
* executing `deploy:finalize_update'
* executing "chmod -R g+w /var/www/myapp/releases/20100204223421"
servers: ["mydomain.com"]
[mydomain.com] executing command
command finished
* executing "rm -rf /var/www/myapp/releases/20100204223421/log /var/www/myapp/releases/20100204223421/public/system /var/www/myapp/releases/20100204223421/tmp/pids &&\\\n mkdir -p /var/www/myapp/releases/20100204223421/public &&\\\n mkdir -p /var/www/myapp/releases/20100204223421/tmp &&\\\n ln -s /var/www/myapp/shared/log /var/www/myapp/releases/20100204223421/log &&\\\n ln -s /var/www/myapp/shared/system /var/www/myapp/releases/20100204223421/public/system &&\\\n ln -s /var/www/myapp/shared/pids /var/www/myapp/releases/20100204223421/tmp/pids"
servers: ["mydomain.com"]
[mydomain.com] executing command
command finished
triggering after callbacks for `deploy:update_code'
* executing `bundler:bundle_new_release'
* executing "cd /var/www/myapp/releases/20100204223421 && bundle install --without test"
servers: ["mydomain.com"]
[mydomain.com] executing command
*** [err :: mydomain.com] sh: bundle: not found
command finished
*** [deploy:update_code] rolling back
* executing "rm -rf /var/www/myapp/releases/20100204223421; true"
servers: ["mydomain.com"]
[mydomain.com] executing command
command finished
failed: "sh -c \"cd /var/www/myapp/releases/20100204223421 && bundle install --without test\"" on mydomain.com
set :application, "myapp"
set :domain, "mydomain.com"
set :repository, "[email protected]:/home/git/myapp.git"
set :deploy_to, "/var/www/#{application}"
set :scm, :git
set :normalize_asset_timestamps, false
set :user, "deployer"
set :use_sudo, false
role :app, "mydomain.com"
role :web, "mydomain.com"
role :db, "mydomain.com", :primary => true
namespace :deploy do
desc "Start the application server"
task :start, :roles => :app do
# run "touch #{current_release}/tmp/restart.txt"
run "/etc/init.d/thin start"
end
desc "Stop the application server"
task :stop, :roles => :app do
run "/etc/init.d/thin stop"
end
desc "Restart the application server"
task :restart, :roles => :app do
# run "touch #{current_release}/tmp/restart.txt"
run "/etc/init.d/thin restart"
end
task :migrate, :roles => :db do
# Do nothing, hooks will handle this later
end
end
namespace :app do
desc "Create the app-specific folders in shared"
task :setup, :roles => :app do
run "cd #{shared_path}; if [ ! -d 'config' ]; then mkdir -p config; fi;"
run "cd #{shared_path}; if [ ! -d 'tmp/pids' ]; then mkdir -p tmp/pids; fi;"
run "cd #{shared_path}; if [ ! -d 'tmp/sockets' ]; then mkdir -p tmp/sockets; fi;"
end
desc "Upload the settings file"
task :upload_settings, :roles => :app do
upload "config/settings.yml", "#{shared_path}/config/settings.yml", :via => :scp
run "ln -s #{shared_path}/config/settings.yml #{current_release}/config/settings.yml" # create a symlink to current
end
desc "tail production log files"
task :tail_logs, :roles => :app do
begin
run "tail -f #{shared_path}/log/server.log" do |channel, stream, data|
puts # for an extra line break before the host name
puts "#{channel[:host]}: #{data}"
break if stream == :err
end
rescue
# silently ignore the Interrupt
end
end
desc "Show settings in production"
task :show_settings, :roles => :app do
run "cat #{shared_path}/config/settings.yml" do |channel, stream, data|; puts data; end
end
end
namespace :db do
desc "Create the db tables"
task :create, :roles => :db do
run "cd #{current_release}; rake db:create APP_ENV=production" # create the db folder if it doesn't exist
end
desc "Drop the db tables"
task :drop, :roles => :db do
run "cd #{current_release}; rake db:drop APP_ENV=production"
end
desc "Reload the db tables"
task :reload, :roles => :db do
run "cd #{current_release}; rake db:reload APP_ENV=production"
end
desc "Seed the db tables"
task :seed, :roles => :db do
run "cd #{current_release}; rake db:seed APP_ENV=production"
end
desc "Upload the settings file"
task :upload_settings, :roles => :app do
upload "config/database.yml", "#{shared_path}/config/database.yml", :via => :scp
run "ln -s #{shared_path}/config/database.yml #{current_release}/config/database.yml" # create a symlink to current
end
end
namespace :bundler do
task :bundle_new_release do
run "cd #{release_path} && bundle install --without test"
end
end
# HOOKS
after "deploy:setup" do
app.setup
end
after "deploy:update_code" do
bundler.bundle_new_release
end
after "deploy:update" do
app.upload_settings
db.upload_settings
end
after "deploy:cold" do
db.create
db.seed
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment