ecs_compose 0.1.0.pre13 → 0.1.0.pre14

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: a2272a942dcbab9f8fcac63a3dbc542c68fd86ac
4
- data.tar.gz: 3f001cc3617347d0f5481a30dc75562763ae0990
3
+ metadata.gz: 258ad2a5c72320cfcddc857c2ef3bb65b514191b
4
+ data.tar.gz: ddde11787a6c3b444715af2f5139c2e27a00e631
5
5
  SHA512:
6
- metadata.gz: 7f4b853b2e3260adb594529a9bdd21c7999358beac5c0828ab1ecc09c70e8301bae844459ec9d24adf3764832895d55f95b0a9b0689eb45a07a6ad86e7f2406a
7
- data.tar.gz: 68d28497bb0ee507e6749a22ccad039eb1e737c2d77e489ef798c710e516747676279d31b7e700bdfaa6678b24cbc8a0d2a9da12837b34fc855bc8fb8b40120d
6
+ metadata.gz: ddf8db17be5df23a2afa7cd5b968efbc8cdcada1e7321f3d345c528509e431ce06cca31fd140c0b2ff7cd3edacc5b4bf6b8e255a13d83b4dbc8902a100e27b7c
7
+ data.tar.gz: aa1d015f363ed9590c42b75decd8d479b25cd22eb8d5379bd62b5cdc2dfc9c43328e501445ba78f407d4e0daf2457613509c5deba635772bdfd290444afdb61e
data/exe/ecs-compose CHANGED
@@ -12,6 +12,7 @@ Usage:
12
12
  ecs-compose [options] register [<task_def>...]
13
13
  ecs-compose [options] up [<service>...]
14
14
  ecs-compose [options] run [-e <name>=<value>]... [--entrypoint <entrypoint>] <task> [-- [<arg>...]]
15
+ ecs-compose [options] scale (all=<n> | <service>=<m>)...
15
16
  ecs-compose [options] json [<task_def>]
16
17
 
17
18
  Options:
@@ -34,6 +35,7 @@ Commands:
34
35
  register Registers the specified ECS task definitions (defaults to all)
35
36
  up Updates the specified ECS services (defaults to all)
36
37
  run Runs the specified task
38
+ scale Specify how many copies of a service's task should be run
37
39
  json Generate JSON for a specific task definition
38
40
  DOCOPT
39
41
 
@@ -58,14 +60,14 @@ class App
58
60
 
59
61
  # Figure out which subcommand was chosen, and run it.
60
62
  def run
61
- for command in %w{register up run json}
63
+ for command in %w{register up run scale json}
62
64
  if options.fetch(command)
63
65
  send("command_#{command}")
64
66
  return
65
67
  end
66
68
  end
67
69
  # We shouldn't ever get here.
68
- raise "Unknown command: #{command}"
70
+ raise "Unknown command"
69
71
  end
70
72
 
71
73
  protected
@@ -111,6 +113,30 @@ class App
111
113
  EcsCompose::TaskDefinition.wait_for_tasks([arn])
112
114
  end
113
115
 
116
+ def command_scale
117
+ # Technically we could make this work without a manifest.
118
+ available = manifest.task_definitions.select {|td| td.type == :service }
119
+ all_names = available.map {|td| td.name }
120
+ settings = options.fetch("<service>=<m>")
121
+ scales = {}
122
+ for setting in settings
123
+ setting =~ /\A([-_A-Za-z0-9]+)=(\d+)\z/ or
124
+ fatal_err("Can't parse '#{setting}'")
125
+ name, count = $1, $2.to_i
126
+ if name == 'all'
127
+ all_names.each {|n| scales[n] = count }
128
+ else
129
+ scales[name] = count
130
+ end
131
+ end
132
+ service_names = scales.map do |name, count|
133
+ service = available.find {|td| td.name == name } or
134
+ raise "Unknown service: #{name}"
135
+ service.scale(count)
136
+ end
137
+ EcsCompose::TaskDefinition.wait_for_services(service_names)
138
+ end
139
+
114
140
  def command_json
115
141
  task_definition = options.fetch('<task_def>')[0]
116
142
  if task_definition.nil?
@@ -53,6 +53,13 @@ module EcsCompose
53
53
  "--task-definition", task_definition)
54
54
  end
55
55
 
56
+ # Update the specified service. Sample args: `"frontend"`, `3`.
57
+ def self.update_service_desired_count(service, desired_count)
58
+ run("update-service",
59
+ "--service", service,
60
+ "--desired-count", desired_count.to_s)
61
+ end
62
+
56
63
  # Run a one-off task. Sample args: `"migrator:1"`. The overrides may
57
64
  # be specified in the JSON format used by `aws ecs run-task`.
58
65
  def self.run_task(task_definition, overrides_json: nil)
@@ -33,6 +33,12 @@ module EcsCompose
33
33
  name
34
34
  end
35
35
 
36
+ # Set the number of running copies of a service we want to have.
37
+ def scale(count)
38
+ Ecs.update_service_desired_count(name, count)
39
+ name
40
+ end
41
+
36
42
  # Wait for a set of services to reach a steady state.
37
43
  def self.wait_for_services(service_names)
38
44
  Ecs.wait_services_stable(service_names)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecs_compose
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre13
4
+ version: 0.1.0.pre14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Kidd
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-10 00:00:00.000000000 Z
11
+ date: 2015-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docopt