Class: Capistrano::ASG::Rolling::Plugin
- Inherits:
-
Plugin
- Object
- Plugin
- Capistrano::ASG::Rolling::Plugin
- Defined in:
- lib/capistrano/asg/rolling/plugin.rb
Overview
Load this Capistrano Plugin in your Capfile:
require ‘capistrano/asg/rolling’ install_plugin Capistrano::ASG::Rolling::Plugin
Instance Method Summary collapse
- #cleanup ⇒ Object
- #config ⇒ Object
- #define_tasks ⇒ Object
- #logger ⇒ Object
- #register_hooks ⇒ Object
- #set_defaults ⇒ Object
Instance Method Details
#cleanup ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/capistrano/asg/rolling/plugin.rb', line 50 def cleanup instances = config.instances.auto_terminate return if instances.empty? logger.info 'Terminating instance(s)...' instances.terminate rescue Capistrano::ASG::Rolling::InstanceTerminateFailed => e logger.warning "Failed to terminate Instance **#{e.instance.id}**: #{e.}" end |
#config ⇒ Object
46 47 48 |
# File 'lib/capistrano/asg/rolling/plugin.rb', line 46 def config Capistrano::ASG::Rolling::Configuration end |
#define_tasks ⇒ Object
38 39 40 |
# File 'lib/capistrano/asg/rolling/plugin.rb', line 38 def define_tasks eval_rakefile File.('../tasks/rolling.rake', __dir__) end |
#logger ⇒ Object
42 43 44 |
# File 'lib/capistrano/asg/rolling/plugin.rb', line 42 def logger @logger ||= Logger.new(verbose: config.verbose?) end |
#register_hooks ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/capistrano/asg/rolling/plugin.rb', line 21 def register_hooks Capistrano::DSL.stages.each do |stage| after stage, 'rolling:setup' end after 'deploy', 'rolling:update' after 'deploy:failed', 'rolling:cleanup' after 'rolling:update', 'rolling:cleanup' after 'rolling:create_ami', 'rolling:cleanup' after 'rolling:update', 'rolling:instance_refresh_status' # Register an exit hook to do some cleanup when Capistrano # terminates without calling our after cleanup hook. at_exit { cleanup } end |
#set_defaults ⇒ Object
14 15 16 17 18 19 |
# File 'lib/capistrano/asg/rolling/plugin.rb', line 14 def set_defaults set_if_empty :asg_rolling_group_name, ENV.fetch('asg_name', nil) set_if_empty :asg_rolling_use_private_ip_address, true set_if_empty :asg_rolling_verbose, true set_if_empty :asg_rolling_update, true end |