deployme 0.1.9 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ed8d43f183d6b8fa190320480936a3497ff0ade8f10e3d1f96326174d97cbdc
4
- data.tar.gz: 8c0f497b716a4bcbc4165fc3981c973f8e5bed65b077be8329c08c313a332e5a
3
+ metadata.gz: 818c46100359f8dc6b33f8d8b794273323d375e7e5b710310e12489974a61f08
4
+ data.tar.gz: a108b1c68aaade6df935d8e369886aaa151d61f170b782c4744b9d84c276ca21
5
5
  SHA512:
6
- metadata.gz: 0fa97b83a51a673fa0fe3b6f6594d66627e89b7d5e4462873c3fa34eda329441252b853ffe84ccea56709c268ab2b668e2d32d5932f5511f881b5cf03c5a2a49
7
- data.tar.gz: 25205176b7692bbd6c814918173f8ce2cc371cdf1e91de557b87f7e88112f7af6656aa82eb5f8db5afbf35be85a7322538e0718b36a2c7156e8a9481c01370d9
6
+ metadata.gz: 356aa29e4fcbec2970874c68cfe4d6398de2b1f3e1448f7e466507a3bf4ff65fd9a6311a53ca6a3b65c7f914ef14823cf849e0d3ac473dd1e2f9bd2ca65e5eac
7
+ data.tar.gz: 5f2f3df307fc9811b671515d62a0d2f11fe40fff855d9cfb2fca6cccdf9960877783bba69d08af81d7e3739a7382722be388ccd305c41322bb11abe199a02c17
@@ -11,6 +11,7 @@ module Deployme
11
11
  def execute
12
12
  return if options.dry_run
13
13
  register_tasks
14
+ run_tasks
14
15
  register_services
15
16
  end
16
17
 
@@ -58,6 +59,62 @@ module Deployme
58
59
  end
59
60
  end
60
61
 
62
+ def report_run_task_failures(failures)
63
+ return if failures.empty?
64
+ failures.each do |failure|
65
+ STDERR.puts "Error: run task failure '#{failure.reason}'"
66
+ end
67
+ exit 1
68
+ end
69
+
70
+ # handle one off tasks
71
+ def run_tasks
72
+ config.fetch(:one_off_commands, []).each do |one_off_command|
73
+ task_definition = task_definitions[one_off_command[:task_family].to_sym]
74
+ logger.info "Running '#{one_off_command[:command]}'"
75
+ response = client.run_task(
76
+ cluster: options.ecs_cluster,
77
+ task_definition: task_definition[:arn],
78
+ count: 1,
79
+ started_by: "ecs-deploy: one_off_commands",
80
+ overrides: {
81
+ container_overrides: [
82
+ {
83
+ name: task_definition[:container_definitions].first[:name],
84
+ command: Array(one_off_command[:command])
85
+ }
86
+ ]
87
+ }
88
+ )
89
+ # handle potential failures
90
+ report_run_task_failures(response.failures)
91
+
92
+ 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
109
+ end
110
+ if task.containers.first.exit_code != 0
111
+ STDERR.puts "Error: '#{one_off_command[:command]}' finished with a non-zero exit code! Aborting."
112
+ exit 1
113
+ end
114
+ puts " done!"
115
+ end
116
+ end
117
+
61
118
  def task_definitions
62
119
  @task_definitions ||= {}
63
120
  end
@@ -1,3 +1,3 @@
1
1
  module Deployme
2
- VERSION = '0.1.9'.freeze
2
+ VERSION = '0.2.0'.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.1.9
4
+ version: 0.2.0
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-06-25 00:00:00.000000000 Z
11
+ date: 2018-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-ecs