You are currently browsing the tag archive for the ‘Capistrano’ tag.
- current_release only works in deployment
- current_path only works after deployment
- latest_release only works when all servers have the same timestamp for ‘latest release’
- current_release_or_path is always correct
def current_release_or_path
exists?(:deploy_timestamped) ? current_release : current_path
end
I just spend half an our figuring out how to check if a file exists on the remote machine,
File.exist? wont do the trick…
def file_exist?(path)
begin
run "ls #{path}"
return true
rescue Exception => e
return false
end
end
Just run a rake task without having to setup a special capistrano task.
Usage
cap rake:invoke COMMAND="db:migrate" #yes, its a silly example...
Setup
namespace :rake do
task :invoke do
if ENV['COMMAND'].to_s.strip == ''
puts "USAGE: cap rake:invoke COMMAND='db:migrate'"
else
run "cd #{current_path} && RAILS_ENV=production sudo rake #{ENV['COMMAND']}"
end
end
end
Update:
- the basic installation can be done via “passenger-install-apache2-module –auto”
- a better script that does the whole job can be found in cap-recipes
Took me some minutes to figure this out, so here for your laziness-pleasure (for Ubuntu):
Usage
To install passenger or update to the newest release:
cap install_passenger
Install
#deploy.rb
desc "Install Passenger"
task :install_passenger do
install_passenger_module
config_passenger
end
desc "Install Passenger Module"
task :install_passenger_module do
sudo "gem install passenger --no-ri --no-rdoc"
input = ''
run "sudo passenger-install-apache2-module" do |ch,stream,out|
next if out.chomp == input.chomp || out.chomp == ''
print out
ch.send_data(input = $stdin.gets) if out =~ /(Enter|ENTER)/
end
end
desc "Configure Passenger"
task :config_passenger do
version = 'ERROR'#default
#passenger (2.0.3, 1.0.5)
run("gem list | grep passenger") do |ch, stream, data|
version = data.sub(/passenger \(([^,]+).*/,"\\1").strip
end
puts " passenger version #{version} configured"
passenger_config =<<-EOF
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-#{version}/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-#{version}
PassengerRuby /usr/bin/ruby1.8
EOF
put passenger_config, "src/passenger"
sudo "mv src/passenger /etc/apache2/conf.d/passenger"
end
Source
Basic recipe
