Class: Capistrano::DataPlaneApi::Deploy::Group
- Inherits:
-
Object
- Object
- Capistrano::DataPlaneApi::Deploy::Group
- Defined in:
- lib/capistrano/data_plane_api/deploy/group.rb
Overview
Class which deploys the app to all servers in a particular HAProxy backend/group.
Instance Attribute Summary collapse
-
#backend ⇒ Object
readonly
: Configuration::Backend?.
-
#deployment_stats ⇒ Object
readonly
: DeploymentStats.
-
#servers ⇒ Object
readonly
: Array?.
-
#state ⇒ Object
readonly
: Symbol.
Class Method Summary collapse
-
.call(args) ⇒ Object
: (Args) -> DeploymentStats.
Instance Method Summary collapse
-
#call ⇒ Object
Carries out the deployment and returns the stats.
-
#initialize(args) ⇒ Group
constructor
: (Args) -> void.
Constructor Details
#initialize(args) ⇒ Group
: (Args) -> void
30 31 32 33 34 35 36 |
# File 'lib/capistrano/data_plane_api/deploy/group.rb', line 30 def initialize(args) @args = args @deployment_stats = DeploymentStats.new #: DeploymentStats @backend = nil #: Configuration::Backend? @servers = nil #: Array[Configuration::Server]? @state = :pending #: Symbol end |
Instance Attribute Details
#backend ⇒ Object (readonly)
: Configuration::Backend?
18 19 20 |
# File 'lib/capistrano/data_plane_api/deploy/group.rb', line 18 def backend @backend end |
#deployment_stats ⇒ Object (readonly)
: DeploymentStats
24 25 26 |
# File 'lib/capistrano/data_plane_api/deploy/group.rb', line 24 def deployment_stats @deployment_stats end |
#servers ⇒ Object (readonly)
: Array?
21 22 23 |
# File 'lib/capistrano/data_plane_api/deploy/group.rb', line 21 def servers @servers end |
#state ⇒ Object (readonly)
: Symbol
27 28 29 |
# File 'lib/capistrano/data_plane_api/deploy/group.rb', line 27 def state @state end |
Class Method Details
.call(args) ⇒ Object
: (Args) -> DeploymentStats
12 13 14 |
# File 'lib/capistrano/data_plane_api/deploy/group.rb', line 12 def call(args) new(args).call end |
Instance Method Details
#call ⇒ Object
Carries out the deployment and returns the stats
: -> DeploymentStats
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/capistrano/data_plane_api/deploy/group.rb', line 41 def call @backend = ::Capistrano::DataPlaneApi.find_backend(T.must(@args.group)) @servers = get_servers(@backend) start_deployment @servers&.each do |server| server_stats = @deployment_stats[T.must(server.name)] puts COLORS.bold.blue("Deploying the app to `#{server.stage}` -- `#{@backend.name}:#{server.name}`") puts @args.humanized_deploy_command(server.stage) puts next if @args.test? server_stats.start_time = ::Time.now deploy_command = @args.deploy_command(server.stage) case system deploy_command when true @state = :success when false @state = :failed when nil @state = :pending end server_stats.end_time = ::Time.now server_stats.state = @state next if @state == :success puts COLORS.bold.red("Command `#{deploy_command}` failed") break end return @deployment_stats if @args.test? finish_deployment(state: @state) print_summary @deployment_stats end |