require 'railsmachine/recipes/svn' require 'railsmachine/recipes/mysql' require 'railsmachine/recipes/apache' require 'railsmachine/recipes/mongrel' Capistrano.configuration(:must_exist).load do set :app_symlinks, nil desc "Setup servers." task :setup_servers do setup_db setup_app setup_symlinks setup_web end desc "Setup application server." task :setup_app, :roles => :app do set :mongrel_environment, rails_env set :mongrel_port, apache_proxy_port set :mongrel_servers, apache_proxy_servers configure_mongrel_cluster end desc "Restart application server." task :restart_app, :roles => :app do restart_mongrel_cluster end desc "Start application server." task :start_app, :roles => :app do start_mongrel_cluster end desc "Stop application server." task :stop_app, :roles => :app do stop_mongrel_cluster end desc "Setup web server." task :setup_web, :roles => :web do set :apache_server_name, domain unless apache_server_name configure_apache end desc "Restart web server." task :restart_web, :roles => :web do restart_apache end desc "Reload web server configuration." task :reload_web, :roles => :web do reload_apache end desc "Start web server." task :start_web, :roles => :web do start_apache end desc "Stop web server." task :stop_web, :roles => :web do stop_apache end desc "Setup database server." task :setup_db, :roles => :db, :only => { :primary => true } do setup_mysql end desc "Setup source control server." task :setup_scm, :roles => :scm do setup_svn import_svn end desc "Setup public symlink directories" task :setup_symlinks, :roles => [:app, :web] do if app_symlinks app_symlinks.each { |link| run "mkdir -p #{shared_path}/public/#{link}" } end end desc "Link up any public directories." task :symlink_public, :roles => [:app, :web] do if app_symlinks app_symlinks.each { |link| run "ln -nfs #{shared_path}/public/#{link} #{current_path}/public/#{link}" } end end desc <<-DESC Restart the processes on the application server by calling restart_app. DESC task :restart, :roles => :app do restart_app end desc <<-DESC Start the processes on the application server by calling start_app. DESC task :spinner, :roles => :app do start_app end desc "Creates additional symlinks." task :after_symlink, :roles => [:app, :web] do symlink_public end end