Commit 66565c56
Changed files (4)
config
config/recipes/postgresql.rb
@@ -40,20 +40,20 @@ namespace :postgresql do
download("db/backups/#{filename}", "db/backups/", :via => :scp, :recursive => true)
end
+ #desc "Backup the database and copy it locally"
+ #task :backup, roles: :db, only: {primary: true} do
+ #filename = "#{rails_env}-#{Time.now.strftime('%Y-%m-%d-%H-%M')}.dump"
+ #backup_path = "#{shared_path}/backups"
+ #run "mkdir -p #{shared_path}/backups"
+
+ #run "PGPASSWORD='#{postgresql_password}' pg_dump -Fc --no-acl --no-owner -h #{postgresql_host} -U #{postgresql_user} #{postgresql_database} > #{backup_path}/#{filename}"
+ #download("#{backup_path}/#{filename}", "tmp/#{filename}", :via => :scp)
+ #run_locally "cd tmp; rm database.dump; ln -s #{filename} database.dump"
+ #end
+
task :restore do
dumpfile = "~/db/backups/latest"
upload("latest", "db/backups/latest", :via => :scp)
run "psql #{postgresql_database} < #{dumpfile}"
end
end
-
-#namespace :deploy do
- #task :symlink_db, :roles => :app do
- #run "chmod +x #{release_path}/script/restart_delayed_job"
- #run "ln -nfs #{release_path}/config/database.production.yml.example #{release_path}/config/database.yml"
- #end
- #task :restart, :roles => :web do
- #run "touch #{current_path}/tmp/restart.txt"
- #end
-#end
-#after 'deploy:update_code', 'deploy:symlink_db'
config/tasks/rails.rb
@@ -0,0 +1,16 @@
+namespace :rails do
+ desc "Remote console"
+ task :console, :roles => :app do
+ run_interactively "bundle exec rails console #{rails_env}"
+ end
+
+ desc "Remote dbconsole"
+ task :dbconsole, :roles => :app do
+ run_interactively "bundle exec rails dbconsole #{rails_env}"
+ end
+
+ def run_interactively(command, server=nil)
+ server ||= find_servers_for_task(current_task).first
+ exec %Q(ssh #{user}@#{server.host} -t 'cd #{current_path} && #{command}')
+ end
+end
config/tasks/utility.rb
@@ -0,0 +1,4 @@
+desc "tail the logs on an app server (cap qa logs)"
+task :logs, roles: :app do
+ stream "tail -f #{shared_path}/log/#{rails_env}.log"
+end
config/deploy.rb
@@ -10,6 +10,8 @@ load "config/recipes/delayed_job"
#load "config/recipes/rvm"
load "config/recipes/rbenv"
load "config/recipes/monit"
+load "config/tasks/utility"
+load "config/tasks/rails"
set :application, "cakeside"
set :user, "deployer"