Created
November 2, 2010 15:56
-
-
Save anonymous/659823 to your computer and use it in GitHub Desktop.
SHRINE Capfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| load 'deploy' if respond_to?(:namespace) | |
| Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) } | |
| require 'capistrano/ext/multistage' | |
| set :stages, %w(dev test prod) | |
| set :default_stage, "dev" | |
| set :application, 'shrine' | |
| set :scm, :none | |
| set :deploy_to do | |
| "/opt/shrine/#{component}" | |
| end | |
| set :user, 'shrine' | |
| set :cell_war, "../war/target/*.war" | |
| set :sheriff_war, "../sheriff/sheriff-war/target/*.war" | |
| set :deploy_via, :copy | |
| set :repository do | |
| fetch(:deploy_from) | |
| end | |
| set :deploy_dir, "./work/" | |
| set :deploy_from do | |
| dir = "#{deploy_dir}/prep_#{release_name}" | |
| system("mkdir -p #{dir}") | |
| dir | |
| end | |
| namespace :tomcat do | |
| desc "start tomcat" | |
| task :start do | |
| run "nohup $TOMCAT_HOME/bin/startup.sh" | |
| end | |
| desc "stop tomcat" | |
| task :stop do | |
| run "nohup $TOMCAT_HOME/bin/shutdown.sh" | |
| end | |
| desc "tail $TOMCAT_HOME/logs/*.log and logs/catalina.out" | |
| task :tail do | |
| stream "tail -f $TOMCAT_HOME/logs/*.log $TOMCAT_HOME/logs/catalina.out" | |
| end | |
| end | |
| before 'cell:deploy' do | |
| system("cp #{cell_war} #{deploy_from}") | |
| end | |
| namespace :cell do | |
| desc "push the cell artifact and restart tomcat" | |
| task :default, :roles => :cell do | |
| tomcat.stop | |
| cell.deploy | |
| tomcat.start | |
| end | |
| desc "push the cell artifact" | |
| task :deploy, :roles => :cell do | |
| set :component, 'cell' | |
| top.deploy.strategy.deploy! | |
| top.deploy.finalize_update | |
| symlink | |
| end | |
| end | |
| after 'cell:deploy' do | |
| system("rm #{deploy_from}/*") | |
| end | |
| before 'sheriff:deploy' do | |
| system("cp #{sheriff_war} #{deploy_from}") | |
| end | |
| namespace :sheriff do | |
| desc "push the sheriff artifact and restart tomcat" | |
| task :default, :roles => :sheriff do | |
| tomcat.stop | |
| sheriff.deploy | |
| tomcat.start | |
| end | |
| desc "push the sheriff artifact" | |
| task :deploy, :roles => :sheriff do | |
| set :component, 'sheriff' | |
| top.deploy.strategy.deploy! | |
| top.deploy.finalize_update | |
| symlink | |
| end | |
| end | |
| after 'sheriff:deploy' do | |
| system("rm #{deploy_from}/*") | |
| end | |
| #recreate the 'current' symlink to point to the release_path | |
| def symlink | |
| run("rm -f #{current_path} && ln -s #{release_path} #{current_path}") | |
| end | |
| desc "Push all SHRINE-related artifacts and restart the servers" | |
| task :shrine do | |
| tomcat.stop | |
| cell.deploy | |
| reset_variables | |
| sheriff.deploy | |
| tomcat.start | |
| end | |
| #reset all of the existing Capistrano variables, this is needed to allow re-calling deploy tasks for | |
| #the different artifacts | |
| def reset_variables | |
| @variables.each do |k,v| | |
| reset! k | |
| end | |
| end | |
| task :clean do | |
| system("rm -rf #{deploy_dir}") | |
| end | |
| # | |
| # Disable all the default tasks that | |
| # either don't apply, or I haven't made work. | |
| # | |
| namespace :deploy do | |
| [:upload, :cold, :start, :stop, :migrate, :migrations, :finalize_update].each do |the_task| | |
| desc "[internal] disabled" | |
| task the_task do | |
| #do nothing | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment