Skip to content

Instantly share code, notes, and snippets.

@benlieb
Last active December 20, 2015 07:49
Show Gist options
  • Save benlieb/6096098 to your computer and use it in GitHub Desktop.
Save benlieb/6096098 to your computer and use it in GitHub Desktop.
require 'capistrano/ext/multistage'
require 'railsmachine/recipes'
set :application, "REMOVED"
set :domain, "REMOVED.org"
role :web, domain
role :app, domain, :primary => true
role :db, domain, :primary => true
set :user, "deploy"
set :spinner_user, nil
set :runner, user
set :scm, :git
set :repository, "ssh://[email protected]/var/www/apps/REMOVED/REMOVED.git"
#set :deploy_via, :remote_cache
set :git_shallow_clone, 1
#set :ssh_options, {:forward_agent => true}
set :deploy_via, :copy
namespace :web do
task :reload do
nginx.restart
end
end
namespace :db do
task :import do
run "cd #{current_path} && rake RAILS_ENV=#{rails_env} import"
end
end
# Override the defaults here so that we link the public folder to the dreamweaver site
namespace :dw do
namespace :symlinks do
desc "Replace the default railsmachine task"
task :setup, :roles => [:app] do
run "mkdir -p #{deploy_to}/static"
end
desc "Link the file uploads directory appropriately"
task :update, :roles => [:app] do
run "ln -nfs #{deploy_to}/static/files #{release_path}/public/files"
end
desc "Link the database yaml appropriately"
task :database, :roles => [:app] do
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
end
end
end
before "deploy:finalize_update", "dw:symlinks:update", "dw:symlinks:database"
namespace :nginx do
task :start do
sudo "/etc/init.d/nginx start"
end
task :stop do
sudo "/etc/init.d/nginx stop"
end
task :restart do
sudo "/etc/init.d/nginx restart"
end
task :reload do
sudo "/etc/init.d/nginx reload"
end
end
after "deploy:migrations", "deploy:cleanup"
# TODO: look into creating a tunnel for this so it can be automated without storing passwords in different places
# Implement cli prompt
task :rebase_staging_db do
p "ssh REMOVED.org -c 'mysqldump -p REMOVED_production > REMOVED_production.sql'"
p "scp REMOVED.org:/var/www/apps/REMOVED/db/REMOVED_production.sql /var/www/apps/REMOVED/db/production.sql"
p "scp REMOVED:/var/www/apps/REMOVED/db/REMOVED_production.sql production.sql"
p "mysql REMOVED_production -p < /var/www/apps/REMOVED/db/production.sql"
end
task :rebase_static_site do
run "cd #{current_path} && rake content:sync"
end
tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN 2348/ruby1.8
tcp 0 0 127.0.0.1:8001 0.0.0.0:* LISTEN 2351/ruby1.8
tcp 0 0 127.0.0.1:8002 0.0.0.0:* LISTEN 2354/ruby1.8
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 2284/mysqld
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment