Capistrano - Setup log directories and database.yml
Updated my deploy.rb gist.
Created a new setup_config task that should be run the first time you setup your server. This fixes the missing database.yml file, and setups the missing log directories in your Rails app.
Also creates a helper method that checks if a remote_file exists.
# config/deploy.rb
before 'deploy:db:symlink_db', 'deploy:setup_config'
def remote_file_exists?(full_path)
'true' == capture("if [ -e #{full_path} ]; then echo 'true'; fi").strip
end
namespace :deploy do
task :setup_config do
run "mkdir -p #{deploy_to}/shared/config"
run "mkdir -p #{deploy_to}/shared/log"
if remote_file_exists?("#{deploy_to}/shared/config/database.yml")
puts "database.yml exists, continuing on ..."
else
run "cd #{current_release}; cp -u #{current_release}/config/database.yml.example #{deploy_to}/shared/config/database.yml"
end
end
end