ecs_compose 0.1.0.pre11 → 0.1.0.pre12

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
  SHA1:
3
- metadata.gz: d921f9b7cfc815df0f612407f5c4b6a5eb36a242
4
- data.tar.gz: 517f89b2d4b32570307fb789370270b24a211882
3
+ metadata.gz: 9631893f24b9aefdc6fba876721e9cdfb52b2635
4
+ data.tar.gz: 5aea13e1e6d140ead8708fa72d3480fa630e4020
5
5
  SHA512:
6
- metadata.gz: 850739a8d7a033f072c3b8a764a967d428cc28d7402ac69fc002d57e57bb5414cb260945c655023388fa96a5f2b11a75aa3243f99607716db4c7944bc626490f
7
- data.tar.gz: 90a241bc97e878262a503e6310ff30fc8a4bf2b31bb15c05c9f1ee5e690250386b95ad2b4750ae8d7704ea3ff5ce100e6c6ce5180fe534253cf30521aa3dc775
6
+ metadata.gz: 3ddee4ff7648921d0015e29e4aa6190814da7a5119170821509ff42402f8c43b353d80aed6679012afc3151ebb05c1554d5aed3d8e7384289b2e75fc82e5b3ae
7
+ data.tar.gz: d4638ac13bcf415d2cf4e19c7568e9d3636b335a2ee355a99a42be8e63243018d2d46ebf11e83dc416dbe667d2cdfe7dcf20ca99292dce9709a0d41e8ed8f412
data/exe/ecs-compose CHANGED
@@ -79,7 +79,8 @@ class App
79
79
  def command_up
80
80
  available = manifest.task_definitions.select {|td| td.type == :service }
81
81
  chosen = all_or_specified(available, options.fetch('<service>'))
82
- chosen.each {|td| td.update }
82
+ services = chosen.map {|td| td.update }
83
+ EcsCompose::TaskDefinition.wait_for_services(services)
83
84
  end
84
85
 
85
86
  def command_run
@@ -104,9 +105,10 @@ class App
104
105
  command = options.fetch('<arg>')
105
106
  command = nil if command.empty?
106
107
 
107
- task.run(environment: env,
108
- entrypoint: options.fetch('--entrypoint').flatten[0],
109
- command: command)
108
+ arn = task.run(environment: env,
109
+ entrypoint: options.fetch('--entrypoint').flatten[0],
110
+ command: command)
111
+ EcsCompose::TaskDefinition.wait_for_tasks([arn])
110
112
  end
111
113
 
112
114
  def command_json
@@ -3,6 +3,7 @@
3
3
  require 'colorize'
4
4
  require 'json'
5
5
  require 'open3'
6
+ require 'shellwords'
6
7
  require 'tempfile'
7
8
 
8
9
  module EcsCompose
@@ -18,7 +19,7 @@ module EcsCompose
18
19
  # Run `aws ecs` with the specified arguments.
19
20
  def self.run(*args)
20
21
  command = ["aws", "ecs"] + args + ["--output", "json"]
21
- STDERR.puts "→ #{command.join(' ').blue}"
22
+ STDERR.puts "→ #{Shellwords.join(command).blue}"
22
23
  stdout, status = Open3.capture2(*command)
23
24
  if status != 0
24
25
  raise "Error running: #{command.inspect}"
@@ -62,14 +63,23 @@ module EcsCompose
62
63
  *extra_args)
63
64
  end
64
65
 
65
- def self.wait_tasks_stopped(*arns)
66
+ # Wait until all of the specified services have reached a stable state.
67
+ # Returns nil.
68
+ def self.wait_services_stable(services)
69
+ run("wait", "services-stable",
70
+ "--services", *services)
71
+ end
72
+
73
+ # Wait until all of the specified tasks have stopped. Returns nil.
74
+ def self.wait_tasks_stopped(arns)
66
75
  run("wait", "tasks-stopped",
67
- "--tasks", arns.join(" "))
76
+ "--tasks", *arns)
68
77
  end
69
78
 
70
- def self.describe_tasks(*arns)
79
+ # Describe a set of tasks as JSON.
80
+ def self.describe_tasks(arns)
71
81
  run("describe-tasks",
72
- "--tasks", arns.join(" "))
82
+ "--tasks", *arns)
73
83
  end
74
84
  end
75
85
  end
@@ -30,6 +30,13 @@ module EcsCompose
30
30
  # service.
31
31
  def update
32
32
  Ecs.update_service(name, register)
33
+ name
34
+ end
35
+
36
+ # Wait for a set of services to reach a steady state.
37
+ def self.wait_for_services(service_names)
38
+ Ecs.wait_services_stable(service_names)
39
+ # TODO: Check for errors during stabilization.
33
40
  end
34
41
 
35
42
  # Run this task definition as a one-shot ECS task, with the specified
@@ -37,12 +44,13 @@ module EcsCompose
37
44
  def run(**args)
38
45
  overrides_json = json_generator.generate_override_json(**args)
39
46
  info = Ecs.run_task(register, overrides_json: overrides_json)
40
- arn = info.fetch("tasks")[0].fetch("taskArn")
41
- #STDERR.puts("Running as: #{arn}")
47
+ info.fetch("tasks")[0].fetch("taskArn")
48
+ end
42
49
 
43
- # Wait until the task has finished running and check for errors.
44
- Ecs.wait_tasks_stopped(arn)
45
- TaskError.fail_on_errors(Ecs.describe_tasks(arn))
50
+ # Wait for a set of tasks to finish, and raise an error if they fail.
51
+ def self.wait_for_tasks(task_arns)
52
+ Ecs.wait_tasks_stopped(task_arns)
53
+ TaskError.fail_on_errors(Ecs.describe_tasks(task_arns))
46
54
  end
47
55
 
48
56
  # Generate ECS task definition JSON for this instance.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecs_compose
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre11
4
+ version: 0.1.0.pre12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Kidd