Skip to content

Instantly share code, notes, and snippets.

@robinboening
Created March 30, 2015 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robinboening/c660ebc2d7020d7df86e to your computer and use it in GitHub Desktop.
Save robinboening/c660ebc2d7020d7df86e to your computer and use it in GitHub Desktop.
Basic deploy.rb for alchemy_cms
require 'bundler/capistrano'
require 'alchemy/capistrano'
require 'capistrano/ext/multistage'
set :bundle_without, %w(development test)
set :bundle_flags, "--deployment --binstubs"
set :use_sudo, false
set :scm, :git
set :repository, "ssh://user@url.com/to/your/repo.git"
set :ssh_options, { :forward_agent => true }
# multistage support
set :stages, %w(staging production)
set :default_stage, :staging
# run in pty to allow remote commands via ssh
default_run_options[:pty] = true
set :user, "your_user"
set :deploy_to, "/your/remote/deploy/path"
# before hooks
before "deploy:start", "deploy:seed"
before "deploy:create_symlink", "deploy:migrate"
# after hooks
after "deploy:setup", "alchemy:database_yml:create"
after "deploy:finalize_update", "alchemy:database_yml:symlink"
after "deploy", "deploy:cleanup"
namespace :log do
desc "show last 100 lines of production.log"
task :show do
run "tail -n100 #{shared_path}/log/#{rails_env}.log"
end
desc "watch tail of production.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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment