# Modify the following variables for your FAST SVN credentials set :scm_username, 'YOUR_SVN_USERNAME' set :scm_password, 'YOUR_SVN_PASSWORD' # Leave these alone set :keep_releases, 5 set :application, 'ublip' set :user, 'ublip' set :deploy_via, :export set :monit_group, 'mongrel' set :scm, :subversion set :runner, 'ublip' set :rails_env, 'slicehost' set :deploy_to, '/opt/ublip/rails' set :monited, 'n' ssh_options[:paranoid] = false set :db_admin, 'y' task :staging do role :db, "YOUR_FAST_SUBDOMAIN.numerexfast.com", :primary => true role :app, "YOUR_FAST_SUBDOMAIN.numerexfast.com", :mongrel => true set :repository, "https://svn.numerexfast.com/repos/fast/Ublip_v2/branches/YOUR_SVN_BRANCH_NAME/trunk" end # Don't change unless you know what you are doing! after "deploy", "deploy:cleanup" after "deploy:migrations", "deploy:cleanup" after "deploy:update_code","deploy:symlink_configs" # uncomment the following to have a database backup done before every migration # before "deploy:migrate", "db:dump" before "deploy", "daemons:stop" after "deploy", "daemons:start" after "deploy", "setup_db_procs" after "deploy:migrate", "setup_db_procs" after "deploy:migrations", "setup_db_procs" # ============================================================================= namespace :mongrel do desc <<-DESC Start Mongrel processes on the app server. This uses the :use_sudo variable to determine whether to use sudo or not. By default, :use_sudo is set to true. DESC task :start, :roles => :app do if monited.eql?("y") sudo "/usr/sbin/monit start all -g #{monit_group}" else run "cd /opt/ublip/rails/current; mongrel_rails cluster::start;" end end desc <<-DESC Restart the Mongrel processes on the app server by starting and stopping the cluster. This uses the :use_sudo variable to determine whether to use sudo or not. By default, :use_sudo is set to true. DESC task :restart, :roles => :app do if monited.eql?("y") sudo "/usr/sbin/monit restart all -g #{monit_group}" else run "cd /opt/ublip/rails/current; mongrel_rails cluster::restart;" end end desc <<-DESC Stop the Mongrel processes on the app server. This uses the :use_sudo variable to determine whether to use sudo or not. By default, :use_sudo is set to true. DESC task :stop, :roles => :app do if monited.eql("y") sudo "/usr/sbin/monit stop all -g #{monit_group}" else run "cd /opt/ublip/rails/current; mongrel_rails cluster::stop;" end end desc "Get the status of your mongrels" task :status, :roles => :app do @monit_output ||= { } sudo "/usr/sbin/monit status" do |channel, stream, data| @monit_output[channel[:server].to_s] ||= [ ] @monit_output[channel[:server].to_s].push(data.chomp) end @monit_output.each do |k,v| puts "#{k} -> #{'*'*55}" puts v.join("\n") end end end # ============================================================================= namespace(:deploy) do task :symlink_configs, :roles => :app, :except => {:no_symlink => true} do run <<-CMD cd #{release_path} && ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml && ln -nfs #{shared_path}/config/mongrel_cluster.yml #{release_path}/config/mongrel_cluster.yml CMD end desc "Long deploy will throw up the maintenance.html page and run migrations then it restarts and enables the site again." task :long do transaction do update_code web.disable symlink migrate end restart web.enable end desc "Restart the Mongrel processes on the app server by calling restart_mongrel_cluster." task :restart, :roles => :app do mongrel.restart end desc "Start the Mongrel processes on the app server by calling start_mongrel_cluster." task :spinner, :roles => :app do mongrel.start end desc "Tail the Rails production log for this environment" task :tail_production_logs, :roles => :app do run "tail -f #{shared_path}/log/production.log" do |channel, stream, data| puts # for an extra line break before the host name puts "#{channel[:server]} -> #{data}" break if stream == :err end end end namespace :daemons do desc "Start all daemons" task :start, :roles => :app, :except => {:no_daemons => true} do run "#{current_path}/script/daemons start" end desc "Stop all daemons" task :stop, :roles => :app, :except => {:no_daemons => true} do if FileTest.exist?("#{current_path}/script/daemons") run "#{current_path}/script/daemons stop" end end end