require 'bundler/capistrano' require 'alchemy/capistrano' # application name set :application, "<%= @app_name %>" # ssh settings <%- if @ssh_user.blank? || !@store_credentials -%> set(:user) { Capistrano::CLI.ui.ask('Enter your ssh username: ') } <%- else -%> set :user, "<%= @ssh_user %>" <%- end -%> <%- if @no_ssh_public_keys -%> <%- if @ssh_password.blank? -%> set(:password) { Capistrano::CLI.password_prompt("Enter the password for #{user}: ") } <%- else -%> set :password, "<%= @ssh_password %>" <%- end -%> <%- end -%> <%- if @ssh_port != "22" && !@store_credentials -%> set(:port) { Capistrano::CLI.ui.ask('Enter the ssh port: ') } <%- elsif @ssh_port != "22" && @store_credentials -%> set :port, <%= @ssh_port %> <%- end -%> # domain names role :app, "<%= @server %>" role :web, "<%= @server %>" role :db, "<%= @server %>", :primary => true # the webserver path set :deploy_to, "<%= @deploy_path %>" set :deploy_via, :remote_cache # repository settings <%- if @scm == "svn" -%> set :scm, "subversion" set :repository_url, "<%= @repository_url %>" <%- if @scm_user && @scm_password -%> set :scm_user, "<%= @scm_user %>" set :scm_password, "<%= @scm_password %>" set :repository, Proc.new { "--username #{scm_user} --password #{scm_password} #{repository_url}" } <%- else -%> set :repository, "<%= @repository_url %>" <%- end -%> <%- elsif @scm == "git" -%> set :scm, "git" set :repository, "<%= @repository_url %>" set :branch, "master" <%- end -%> # rails env set :rails_env, "production" # before hooks before "deploy:start", "deploy:seed" <%- if @database_type == "mysql" -%> before "deploy:migrate", "alchemy:db:dump" <%- end -%> before "deploy:create_symlink", "deploy:migrate" # after hooks <%- if @database_type == "mysql" -%> after "deploy:setup", "alchemy:database_yml:create" after "deploy:finalize_update", "alchemy:database_yml:symlink" <%- end -%> after "deploy", "deploy:cleanup" # special tasks namespace :log do desc "show last 100 lines of log" task :show do run "tail -n100 #{shared_path}/log/#{rails_env}.log" end desc "watch tail of log and wait for additional data to be appended to the input" task :watch do stream("tail -f #{shared_path}/log/#{rails_env}.log") end end 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')}" end desc 'Seeds the database' task :seed, :roles => :app, :except => { :no_release => true } do run "cd #{release_path} && #{rake} RAILS_ENV=#{rails_env} db:seed" end end ## defaults # enable bundler binstubs set :bundle_flags, "--deployment --binstubs" # do not use sudo set :use_sudo, false # enable ssh-agent forwarding ssh_options[:forward_agent] = true # Enable git password prompting default_run_options[:pty] = true