deployme 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 818c46100359f8dc6b33f8d8b794273323d375e7e5b710310e12489974a61f08
4
- data.tar.gz: a108b1c68aaade6df935d8e369886aaa151d61f170b782c4744b9d84c276ca21
3
+ metadata.gz: 2092ec13e1c2ec3da76e08c519ac38f4bfce73dad9533ff693057c41251a5fe0
4
+ data.tar.gz: 72b15d3d59fc554bb2dc5ae6189911f10fc9f7b3b2487f67bb7ad35875006cdb
5
5
  SHA512:
6
- metadata.gz: 356aa29e4fcbec2970874c68cfe4d6398de2b1f3e1448f7e466507a3bf4ff65fd9a6311a53ca6a3b65c7f914ef14823cf849e0d3ac473dd1e2f9bd2ca65e5eac
7
- data.tar.gz: 5f2f3df307fc9811b671515d62a0d2f11fe40fff855d9cfb2fca6cccdf9960877783bba69d08af81d7e3739a7382722be388ccd305c41322bb11abe199a02c17
6
+ metadata.gz: 825126a97858836951c81b1f3dcece404d55b3fc857d9be292ef840f6f308a5663d53d16e9567dfb0a4e2cf7b3b549fe836010f0165c1c2d2c8da2393c04407d
7
+ data.tar.gz: 5ecd9848f6a8163e95dae1fb9b1f00292f468d4d6957769609ede0b1588d2e48d67c87d31c1cd3547067a3cd705d7fec2061feefbd8e462cc43c9546be5497ff
@@ -55,7 +55,7 @@ module Deployme
55
55
  end
56
56
  rescue Aws::Waiters::Errors::WaiterFailed => error
57
57
  logger.error "failed waiting for service: #{error.message}"
58
- exit(1)
58
+ raise('Failed to deploy')
59
59
  end
60
60
  end
61
61
 
@@ -64,7 +64,7 @@ module Deployme
64
64
  failures.each do |failure|
65
65
  STDERR.puts "Error: run task failure '#{failure.reason}'"
66
66
  end
67
- exit 1
67
+ raise('Failed to deploy')
68
68
  end
69
69
 
70
70
  # handle one off tasks
@@ -72,11 +72,12 @@ module Deployme
72
72
  config.fetch(:one_off_commands, []).each do |one_off_command|
73
73
  task_definition = task_definitions[one_off_command[:task_family].to_sym]
74
74
  logger.info "Running '#{one_off_command[:command]}'"
75
+
75
76
  response = client.run_task(
76
77
  cluster: options.ecs_cluster,
77
78
  task_definition: task_definition[:arn],
78
79
  count: 1,
79
- started_by: "ecs-deploy: one_off_commands",
80
+ started_by: 'ecs-deploy: one_off_commands',
80
81
  overrides: {
81
82
  container_overrides: [
82
83
  {
@@ -90,28 +91,27 @@ module Deployme
90
91
  report_run_task_failures(response.failures)
91
92
 
92
93
  task_arn = response.tasks.first.task_arn
93
- print "Waiting for '#{one_off_command[:command]}' to finish"
94
- waiting = 0
95
- last_now = Time.now
96
- task = nil
97
- while waiting <= 1800 do
98
- task = client.describe_tasks(tasks: [task_arn], cluster: options.ecs_cluster).tasks.first
99
- break if task.last_status == "STOPPED"
100
- print "."
101
- now = Time.now
102
- waiting += (now - last_now).to_i
103
- last_now = now
104
- sleep 5
105
- end
106
- if waiting > 1800
107
- STDERR.puts "Error: wait time exceeded"
108
- exit 1
94
+ logger.info "Task: #{task_arn}"
95
+ begin
96
+ client.wait_until(:tasks_stopped, cluster: options.ecs_cluster, tasks: [task_arn]) do |w|
97
+ w.before_wait do
98
+ logger.info 'Waiting for task to finish...'
99
+ end
100
+ end
101
+ rescue Aws::Waiters::Errors::WaiterFailed => error
102
+ logger.error "failed waiting for task: #{error.message}"
103
+ raise('Failed to deploy')
109
104
  end
110
- if task.containers.first.exit_code != 0
105
+
106
+ task = client.describe_tasks(tasks: [task_arn], cluster: options.ecs_cluster).tasks.first
107
+ container = task.containers.find { |c| c.name == task_definition[:container_definitions].first[:name] }
108
+ if container.exit_code != 0
111
109
  STDERR.puts "Error: '#{one_off_command[:command]}' finished with a non-zero exit code! Aborting."
112
- exit 1
110
+ STDERR.puts "Exit code: #{task.containers.first.exit_code}"
111
+ STDERR.puts " #{task.containers.first.reason}"
112
+ raise('Failed to deploy')
113
113
  end
114
- puts " done!"
114
+ puts ' done!'
115
115
  end
116
116
  end
117
117
 
@@ -1,3 +1,3 @@
1
1
  module Deployme
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.2.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deployme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikko Kokkonen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-03 00:00:00.000000000 Z
11
+ date: 2018-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-ecs