putpaws 1.0.0 → 1.0.1
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/README.md +6 -0
- data/lib/putpaws/ecs/launch_request.rb +17 -0
- data/lib/putpaws/ecs/tasks/ecs_task.rake +10 -8
- data/lib/putpaws/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 332622c0e037c76c87063d8f22ce11cdda8b56e1f4ae88544afc744ced595da0
|
|
4
|
+
data.tar.gz: e656d284a052e9f32e862fa1ffd471f60f48eff326508dd41d2f91530cbc0676
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c3b1551b98c8a029513ec41d401aba54db2e2488742faef27871b88934dbb61bfffdd852a78644bbf9b372976ad535a06cfb8d44272e676c53c63a859aff8a1a
|
|
7
|
+
data.tar.gz: 63618576e04d4fbc2951a08e66c81ee329724da2ff1496d68004c8d7193daf1c93901ed7fe1b293781ec4144142547c30f413017d0c9bcac65f5d898b8ec302a
|
data/README.md
CHANGED
|
@@ -251,6 +251,7 @@ bundle exec putpaws awesome-api-staging ecs:run launch=seed dry=true
|
|
|
251
251
|
| `capacity_provider=` / `task_role=` / `ephemeral_storage=` | `FARGATE` or `FARGATE_SPOT` / task role ARN / GiB |
|
|
252
252
|
| `save=name` | save the resolved launch into `launch.json` under that name. An existing name shows the diff and asks first |
|
|
253
253
|
| `dry=true` | show the resolved launch and start nothing |
|
|
254
|
+
| `started_by=` / `group=` | `startedBy` / `group` of the started task. Default `putpaws-run` (`putpaws-shell` on `ecs:shell`); never saved into a launch |
|
|
254
255
|
| `wait=true` / `ttl=` / `keep=true` | how this run behaves; never saved into a launch |
|
|
255
256
|
|
|
256
257
|
With neither `launch=` nor `target=` / `network=`, the launches of the environment are listed to choose from.
|
|
@@ -274,6 +275,11 @@ bundle exec putpaws awesome-api-staging ecs:shell launch=app keep=true
|
|
|
274
275
|
|
|
275
276
|
Temporary tasks are launched with `group` / `started_by` set to `putpaws-run` or `putpaws-shell`,
|
|
276
277
|
so you can identify them on the AWS console and on the task list of `ecs:attach` / `ecs:forward`.
|
|
278
|
+
Pass `started_by=` / `group=` to label a run yourself, Ex: to tell who or which job started it.
|
|
279
|
+
|
|
280
|
+
```
|
|
281
|
+
bundle exec putpaws awesome-api-staging ecs:run launch=seed started_by=nightly-batch group=seed
|
|
282
|
+
```
|
|
277
283
|
|
|
278
284
|
### Launch
|
|
279
285
|
|
|
@@ -11,6 +11,7 @@ module Putpaws::Ecs
|
|
|
11
11
|
# target=... network=... cmd='...' assembled on the spot, nothing saved
|
|
12
12
|
# save=seed-small save what was resolved under that name
|
|
13
13
|
# dry=true show what was resolved, start nothing
|
|
14
|
+
# started_by=... group=... label the started task (not part of a launch)
|
|
14
15
|
class LaunchRequest
|
|
15
16
|
# command-line parameter => launch field
|
|
16
17
|
OVERRIDE_PARAMS = {
|
|
@@ -65,6 +66,22 @@ module Putpaws::Ecs
|
|
|
65
66
|
present?('save') ? params['save'].strip : nil
|
|
66
67
|
end
|
|
67
68
|
|
|
69
|
+
# How the started task is labeled on ECS (RunTask startedBy / group), so
|
|
70
|
+
# that it can be told apart from the tasks of the service. Like wait= and
|
|
71
|
+
# ttl=, this belongs to the run and is never saved into a launch.
|
|
72
|
+
def started_by(default)
|
|
73
|
+
present?("started_by") ? params["started_by"].strip : default
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def group(default)
|
|
77
|
+
present?("group") ? params["group"].strip : default
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# The labels of this run, for RunCommand#run_ecs_task.
|
|
81
|
+
def labels(default)
|
|
82
|
+
{started_by: started_by(default), group: group(default)}
|
|
83
|
+
end
|
|
84
|
+
|
|
68
85
|
def launch_config
|
|
69
86
|
if present?('launch')
|
|
70
87
|
return Putpaws::LaunchConfig.find!(application, params['launch'].strip)
|
|
@@ -58,23 +58,24 @@ namespace :ecs do
|
|
|
58
58
|
system(*cmd)
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
-
desc "Run a command on a temporary ECS task started from a launch. The task terminates itself when the command finishes. (Ex) launch=app cmd='bundle exec rake db:migrate' wait=true cpu=1024 memory=2048 save=name dry=true"
|
|
61
|
+
desc "Run a command on a temporary ECS task started from a launch. The task terminates itself when the command finishes. (Ex) launch=app cmd='bundle exec rake db:migrate' wait=true cpu=1024 memory=2048 save=name dry=true started_by=name group=name"
|
|
62
62
|
task :run do
|
|
63
63
|
request = Putpaws::Ecs::LaunchRequest.new(application: fetch(:app), prompt: Putpaws::Prompt.safe)
|
|
64
|
+
labels = request.labels('putpaws-run')
|
|
64
65
|
launch = request.resolve
|
|
65
66
|
if launch.command.nil? && !request.dry?
|
|
66
67
|
raise Putpaws::Error, "Please specify a command like: cmd='bundle exec rake db:migrate' (or save `command` in the launch)"
|
|
67
68
|
end
|
|
68
69
|
next unless request.save!(launch)
|
|
69
70
|
if request.dry?
|
|
70
|
-
puts JSON.pretty_generate(launch.describe)
|
|
71
|
+
puts JSON.pretty_generate(launch.describe.merge(labels))
|
|
71
72
|
next
|
|
72
73
|
end
|
|
73
74
|
|
|
74
75
|
runner = Putpaws::Ecs::RunCommand.new(launch)
|
|
75
|
-
ecs_task = runner.run_ecs_task(
|
|
76
|
+
ecs_task = runner.run_ecs_task(**labels)
|
|
76
77
|
task_id = ecs_task.task_arn.split('/').last
|
|
77
|
-
puts "Task started: #{task_id} [
|
|
78
|
+
puts "Task started: #{task_id} [#{labels[:group]}]"
|
|
78
79
|
|
|
79
80
|
if ENV['wait']
|
|
80
81
|
puts "Waiting for the task to stop..."
|
|
@@ -121,24 +122,25 @@ namespace :ecs do
|
|
|
121
122
|
end
|
|
122
123
|
end
|
|
123
124
|
|
|
124
|
-
desc "Start a temporary ECS task from a launch and attach to it. The command is replaced by sleep, so the task terminates itself when ttl passes (default 30m). (Ex) launch=app ttl=45m keep=true cpu=256 memory=512 dry=true"
|
|
125
|
+
desc "Start a temporary ECS task from a launch and attach to it. The command is replaced by sleep, so the task terminates itself when ttl passes (default 30m). (Ex) launch=app ttl=45m keep=true cpu=256 memory=512 dry=true started_by=name group=name"
|
|
125
126
|
task :shell do
|
|
126
127
|
request = Putpaws::Ecs::LaunchRequest.new(application: fetch(:app), prompt: Putpaws::Prompt.safe)
|
|
128
|
+
labels = request.labels('putpaws-shell')
|
|
127
129
|
ttl = Putpaws::Ecs::RunCommand.parse_ttl(ENV['ttl'])
|
|
128
130
|
resolved = request.resolve
|
|
129
131
|
next unless request.save!(resolved)
|
|
130
132
|
# Everything follows the launch except the command.
|
|
131
133
|
launch = resolved.with(command: "sleep #{ttl}")
|
|
132
134
|
if request.dry?
|
|
133
|
-
puts JSON.pretty_generate(launch.describe)
|
|
135
|
+
puts JSON.pretty_generate(launch.describe.merge(labels))
|
|
134
136
|
next
|
|
135
137
|
end
|
|
136
138
|
|
|
137
139
|
runner = Putpaws::Ecs::RunCommand.new(launch)
|
|
138
140
|
puts "Launching a temporary task which terminates itself after #{ttl} seconds"
|
|
139
|
-
ecs_task = runner.run_ecs_task(
|
|
141
|
+
ecs_task = runner.run_ecs_task(**labels)
|
|
140
142
|
task_id = ecs_task.task_arn.split('/').last
|
|
141
|
-
puts "Task started: #{task_id} [
|
|
143
|
+
puts "Task started: #{task_id} [#{labels[:group]}]"
|
|
142
144
|
|
|
143
145
|
begin
|
|
144
146
|
puts "Waiting for the task to be attachable..."
|
data/lib/putpaws/version.rb
CHANGED