ecs_compose 0.1.0.pre11 → 0.1.0.pre12
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 +4 -4
- data/exe/ecs-compose +6 -4
- data/lib/ecs_compose/ecs.rb +15 -5
- data/lib/ecs_compose/task_definition.rb +13 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9631893f24b9aefdc6fba876721e9cdfb52b2635
|
4
|
+
data.tar.gz: 5aea13e1e6d140ead8708fa72d3480fa630e4020
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
|
-
|
109
|
-
|
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
|
data/lib/ecs_compose/ecs.rb
CHANGED
@@ -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 "→ #{
|
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
|
-
|
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
|
76
|
+
"--tasks", *arns)
|
68
77
|
end
|
69
78
|
|
70
|
-
|
79
|
+
# Describe a set of tasks as JSON.
|
80
|
+
def self.describe_tasks(arns)
|
71
81
|
run("describe-tasks",
|
72
|
-
"--tasks", arns
|
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
|
-
|
41
|
-
|
47
|
+
info.fetch("tasks")[0].fetch("taskArn")
|
48
|
+
end
|
42
49
|
|
43
|
-
|
44
|
-
|
45
|
-
|
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.
|