iron_worker_ng 0.10.2 → 0.10.3
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/iron_worker +130 -323
- data/lib/iron_worker_ng/cli.rb +275 -0
- data/lib/iron_worker_ng/client.rb +32 -20
- data/lib/iron_worker_ng/code/base.rb +45 -37
- data/lib/iron_worker_ng/code/builder.rb +4 -3
- data/lib/iron_worker_ng/code/container/base.rb +31 -0
- data/lib/iron_worker_ng/code/container/dir.rb +31 -0
- data/lib/iron_worker_ng/code/container/zip.rb +30 -0
- data/lib/iron_worker_ng/code/runtime/binary.rb +1 -3
- data/lib/iron_worker_ng/code/runtime/go.rb +1 -3
- data/lib/iron_worker_ng/code/runtime/java.rb +2 -3
- data/lib/iron_worker_ng/code/runtime/mono.rb +1 -3
- data/lib/iron_worker_ng/code/runtime/node.rb +1 -3
- data/lib/iron_worker_ng/code/runtime/perl.rb +1 -3
- data/lib/iron_worker_ng/code/runtime/php.rb +1 -3
- data/lib/iron_worker_ng/code/runtime/python.rb +1 -3
- data/lib/iron_worker_ng/code/runtime/ruby.rb +11 -9
- data/lib/iron_worker_ng/feature/base.rb +14 -20
- data/lib/iron_worker_ng/feature/common/merge_dir.rb +14 -5
- data/lib/iron_worker_ng/feature/common/merge_exec.rb +79 -0
- data/lib/iron_worker_ng/feature/common/merge_file.rb +13 -4
- data/lib/iron_worker_ng/feature/java/merge_jar.rb +12 -0
- data/lib/iron_worker_ng/feature/ruby/merge_gem.rb +11 -55
- data/lib/iron_worker_ng/feature/ruby/merge_gem_dependency.rb +76 -0
- data/lib/iron_worker_ng/fetcher.rb +39 -18
- data/lib/iron_worker_ng/version.rb +1 -1
- metadata +45 -17
- data/lib/iron_worker_ng/code/dir_container.rb +0 -33
- data/lib/iron_worker_ng/feature/binary/merge_exec.rb +0 -51
- data/lib/iron_worker_ng/feature/go/merge_exec.rb +0 -51
- data/lib/iron_worker_ng/feature/java/merge_exec.rb +0 -57
- data/lib/iron_worker_ng/feature/mono/merge_exec.rb +0 -51
- data/lib/iron_worker_ng/feature/node/merge_exec.rb +0 -51
- data/lib/iron_worker_ng/feature/perl/merge_exec.rb +0 -51
- data/lib/iron_worker_ng/feature/php/merge_exec.rb +0 -51
- data/lib/iron_worker_ng/feature/python/merge_exec.rb +0 -51
- data/lib/iron_worker_ng/feature/ruby/merge_exec.rb +0 -53
data/bin/iron_worker
CHANGED
@@ -2,69 +2,42 @@
|
|
2
2
|
|
3
3
|
require 'optparse'
|
4
4
|
require 'time'
|
5
|
-
require 'iron_worker_ng'
|
6
5
|
|
7
|
-
|
8
|
-
|
6
|
+
require 'iron_worker_ng'
|
7
|
+
require 'iron_worker_ng/cli'
|
9
8
|
|
10
9
|
class IronWorkerCLILoggerFormatter < ::Logger::Formatter
|
11
10
|
def call(severity, time, proname, msg)
|
12
|
-
msg = LOG_ENTRY + msg unless msg.start_with?(LOG_GROUP)
|
11
|
+
msg = IronWorkerNG::CLI::LOG_ENTRY + msg unless msg.start_with?(IronWorkerNG::CLI::LOG_GROUP)
|
12
|
+
|
13
13
|
msg + "\n"
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
IronCore::Logger.logger.formatter = IronWorkerCLILoggerFormatter.new
|
18
18
|
|
19
|
-
|
20
|
-
IronCore::Logger.info 'IronWorkerNG', msg
|
21
|
-
end
|
22
|
-
|
23
|
-
@env = nil
|
24
|
-
@project_id = nil
|
25
|
-
|
26
|
-
def create_client
|
27
|
-
log "#{LOG_GROUP}Detecting Configuration"
|
28
|
-
|
29
|
-
client = IronWorkerNG::Client.new(:env => @env, :project_id => @project_id)
|
30
|
-
|
31
|
-
project = client.projects.get
|
32
|
-
|
33
|
-
log "Project '#{project.name}' with id='#{project.id}'"
|
34
|
-
|
35
|
-
client
|
36
|
-
end
|
19
|
+
@cli = IronWorkerNG::CLI.new
|
37
20
|
|
38
21
|
def common_opts(opts)
|
39
22
|
opts.on('-e', '--env ENV', 'environment') do |v|
|
40
|
-
@env = v
|
23
|
+
@cli.env = v
|
41
24
|
end
|
42
25
|
|
43
26
|
opts.on('--project-id PROJECT_ID', 'project_id') do |v|
|
44
|
-
@project_id = v
|
27
|
+
@cli.project_id = v
|
45
28
|
end
|
46
29
|
end
|
47
30
|
|
48
|
-
def parse_time(str)
|
49
|
-
t = Time.parse(str)
|
50
|
-
|
51
|
-
return nil if t == Time.utc(1)
|
52
|
-
|
53
|
-
def t.to_s
|
54
|
-
strftime('%a %b %-d %T')
|
55
|
-
end
|
56
|
-
|
57
|
-
return t
|
58
|
-
end
|
59
|
-
|
60
31
|
if $*.size == 1 && ($*[0] == '-v' || $*[0] == '--version')
|
61
32
|
puts IronWorkerNG.full_version
|
62
33
|
exit 0
|
63
34
|
end
|
64
35
|
|
65
|
-
|
36
|
+
commands = ['upload', 'queue', 'retry', 'schedule', 'log', 'run', 'install', 'webhook', 'info']
|
37
|
+
|
38
|
+
if $*.size == 0 || (not commands.include?($*[0]))
|
66
39
|
puts 'usage: iron_worker COMMAND [OPTIONS]'
|
67
|
-
puts
|
40
|
+
puts " COMMAND: #{commands.join(', ')}"
|
68
41
|
puts ' run iron_worker COMMAND --help to get more information about each command'
|
69
42
|
exit 1
|
70
43
|
end
|
@@ -78,29 +51,30 @@ if $*.include?('--debug')
|
|
78
51
|
end
|
79
52
|
|
80
53
|
if command == 'upload'
|
54
|
+
params = {}
|
81
55
|
options = {}
|
82
56
|
|
83
|
-
name = nil
|
84
|
-
|
85
57
|
opts = OptionParser.new do |opts|
|
86
58
|
opts.banner = "usage: iron_worker upload CODE_PACKAGE_NAME_OR_PATH_TO_WORKERFILE [OPTIONS]"
|
87
59
|
|
88
|
-
opts.on('-n', '--name NAME', 'override
|
89
|
-
name = v
|
60
|
+
opts.on('-n', '--name NAME', 'override code name') do |v|
|
61
|
+
params[:name] = v
|
90
62
|
end
|
91
63
|
|
92
64
|
opts.on('-c', '--max-concurrency CONCURRENCY', Integer, 'max number of concurrent workers for this code package') do |v|
|
93
65
|
options[:max_concurrency] = v
|
94
66
|
end
|
95
67
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
68
|
+
opts.on('-r', '--retries NUM_RETRIES', Integer, 'max number of automatic retries on task fail') do |v|
|
69
|
+
options[:retries] = v
|
70
|
+
end
|
71
|
+
|
72
|
+
opts.on('-d', '--retries-delay RETRIES_DELAY', Integer, 'delay between each automatic retry') do |v|
|
73
|
+
options[:retries_delay] = v
|
100
74
|
end
|
101
75
|
|
102
|
-
opts.on('-a', '--async', 'don\'t wait for package build') do |v|
|
103
|
-
|
76
|
+
opts.on('-a', '--async', 'don\'t wait for package build if remote build command specified') do |v|
|
77
|
+
params[:async] = true
|
104
78
|
end
|
105
79
|
|
106
80
|
common_opts(opts)
|
@@ -114,104 +88,57 @@ if command == 'upload'
|
|
114
88
|
end
|
115
89
|
|
116
90
|
unless $*.size == 1
|
117
|
-
puts 'Please specify name or path to workerfile'
|
91
|
+
puts 'Please specify code package name or path to workerfile'
|
118
92
|
puts opts
|
119
93
|
exit 1
|
120
94
|
end
|
121
95
|
|
122
|
-
|
123
|
-
|
124
|
-
log "#{LOG_GROUP}Discovering workerfile"
|
125
|
-
|
126
|
-
code = IronWorkerNG::Code::Base.new($*[0])
|
127
|
-
|
128
|
-
code.name(name) if name
|
129
|
-
|
130
|
-
log "Code package name is '#{code.name}'"
|
131
|
-
|
132
|
-
log "Max concurrency set to '#{options[:max_concurrency]}'" if options[:max_concurrency]
|
133
|
-
|
134
|
-
if code.remote_build_command
|
135
|
-
log "#{LOG_GROUP}Remote building '#{code.name}'"
|
136
|
-
|
137
|
-
async = options[:async]
|
138
|
-
|
139
|
-
builder_task_id = client.codes.create(code, options)
|
140
|
-
|
141
|
-
if async
|
142
|
-
log "Check 'https://hud.iron.io/tq/projects/#{client.api.project_id}/jobs/#{builder_task_id}' for more info"
|
143
|
-
else
|
144
|
-
# TODO: output the same info as for builderless upload
|
145
|
-
end
|
146
|
-
else
|
147
|
-
log "#{LOG_GROUP}Uploading code package"
|
148
|
-
|
149
|
-
code_id = client.codes.create(code, options).id
|
150
|
-
code_info = client.codes.get(code_id)
|
151
|
-
|
152
|
-
log "Code package uploaded with id='#{code_id}' and revision='#{code_info.rev}'"
|
153
|
-
log "Check 'https://hud.iron.io/tq/projects/#{client.api.project_id}/code/#{code_id}' for more info"
|
154
|
-
end
|
96
|
+
@cli.upload($*[0], params, options)
|
155
97
|
elsif command == 'queue' || command == 'schedule'
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
priority = nil
|
160
|
-
timeout = nil
|
161
|
-
delay = nil
|
162
|
-
|
163
|
-
start_at = nil
|
164
|
-
end_at = nil
|
165
|
-
run_times = nil
|
166
|
-
run_every = nil
|
167
|
-
|
168
|
-
print_id = false
|
98
|
+
params = {}
|
99
|
+
options = {}
|
169
100
|
|
170
101
|
opts = OptionParser.new do |opts|
|
171
102
|
opts.banner = "usage: iron_worker #{command} CODE_PACKAGE_NAME [OPTIONS]"
|
172
103
|
|
173
104
|
opts.on('-p', '--payload PAYLOAD', String, 'payload to pass') do |v|
|
174
|
-
payload = v
|
105
|
+
params[:payload] = v
|
175
106
|
end
|
176
107
|
|
177
108
|
opts.on('-f', '--payload-file PAYLOAD_FILE', String, 'payload file to pass') do |v|
|
178
|
-
|
109
|
+
params[:payload] = File.read(v)
|
179
110
|
end
|
180
111
|
|
181
112
|
opts.on('--priority PRIORITY', Integer, '0 (default), 1, 2') do |v|
|
182
|
-
priority = v
|
113
|
+
options[:priority] = v
|
183
114
|
end
|
184
115
|
|
185
116
|
opts.on('--timeout TIMEOUT', Integer, 'maximum run time in seconds from 0 to 3600 (default)') do |v|
|
186
|
-
timeout = v
|
117
|
+
options[:timeout] = v
|
187
118
|
end
|
188
119
|
|
189
120
|
opts.on('--delay DELAY', Integer, 'delay before start in seconds') do |v|
|
190
|
-
delay = v
|
121
|
+
options[:delay] = v
|
191
122
|
end
|
192
123
|
|
193
124
|
if command == 'schedule'
|
194
125
|
opts.on('--start-at TIME', 'start task at specified time') do |v|
|
195
|
-
start_at = Time.parse(v)
|
126
|
+
options[:start_at] = Time.parse(v)
|
196
127
|
end
|
197
128
|
|
198
129
|
opts.on('--end-at TIME', 'stop running task at specified time') do |v|
|
199
|
-
end_at = Time.parse(v)
|
130
|
+
options[:end_at] = Time.parse(v)
|
200
131
|
end
|
201
132
|
|
202
133
|
opts.on('--run-times RUN_TIMES', Integer, 'run task no more times than specified') do |v|
|
203
|
-
run_times = v
|
134
|
+
options[:run_times] = v
|
204
135
|
end
|
205
136
|
|
206
137
|
opts.on('--run-every RUN_EVERY', Integer, 'run task every RUN_EVERY seconds') do |v|
|
207
|
-
run_every = v
|
138
|
+
options[:run_every] = v
|
208
139
|
end
|
209
140
|
end
|
210
141
|
|
211
|
-
opts.on('--print-id', 'prints result id') do |v|
|
212
|
-
print_id = true
|
213
|
-
end
|
214
|
-
|
215
142
|
common_opts(opts)
|
216
143
|
end
|
217
144
|
|
@@ -228,49 +155,13 @@ elsif command == 'queue' || command == 'schedule'
|
|
228
155
|
exit 1
|
229
156
|
end
|
230
157
|
|
231
|
-
name = $*[0]
|
232
|
-
|
233
|
-
if payload.nil? and (not payload_file.nil?)
|
234
|
-
payload = File.read(payload_file)
|
235
|
-
end
|
236
|
-
|
237
|
-
options = {}
|
238
|
-
|
239
|
-
options[:priority] = priority unless priority.nil?
|
240
|
-
options[:timeout] = timeout unless timeout.nil?
|
241
|
-
options[:delay] = delay unless delay.nil?
|
242
|
-
|
243
|
-
if command == 'schedule'
|
244
|
-
options[:start_at] = start_at unless start_at.nil?
|
245
|
-
options[:end_at] = end_at unless end_at.nil?
|
246
|
-
options[:run_times] = run_times unless run_times.nil?
|
247
|
-
options[:run_every] = run_every unless run_every.nil?
|
248
|
-
end
|
249
|
-
|
250
|
-
client = create_client
|
251
|
-
|
252
|
-
id = nil
|
253
|
-
|
254
158
|
if command == 'queue'
|
255
|
-
|
256
|
-
|
257
|
-
id = client.tasks.create(name, payload, options).id
|
258
|
-
|
259
|
-
log "#{LOG_GROUP}Worker '#{name}' queued with id='#{id}'"
|
260
|
-
|
261
|
-
log "Check 'https://hud.iron.io/tq/projects/#{client.api.project_id}/jobs/#{id}' for more info"
|
159
|
+
@cli.queue($*[0], params, options)
|
262
160
|
else
|
263
|
-
|
264
|
-
|
265
|
-
id = client.schedules.create(name, payload, options).id
|
266
|
-
|
267
|
-
log "#{LOG_GROUP}Worker '#{name}' scheduled with id='#{id}'"
|
268
|
-
|
269
|
-
log "Check 'https://hud.iron.io/tq/projects/#{client.api.project_id}/scheduled_jobs/#{id}' for more info"
|
161
|
+
@cli.schedule($*[0], params, options)
|
270
162
|
end
|
271
|
-
|
272
|
-
puts id if print_id
|
273
163
|
elsif command == 'retry'
|
164
|
+
params = {}
|
274
165
|
options = {}
|
275
166
|
|
276
167
|
opts = OptionParser.new do |opts|
|
@@ -296,26 +187,16 @@ elsif command == 'retry'
|
|
296
187
|
exit 1
|
297
188
|
end
|
298
189
|
|
299
|
-
|
300
|
-
|
301
|
-
client = create_client
|
302
|
-
|
303
|
-
log "#{LOG_GROUP}Retrying task with id='#{task_id}'"
|
304
|
-
|
305
|
-
retry_task_id = client.tasks.retry(task_id, options).id
|
306
|
-
|
307
|
-
log "Retry task id='#{retry_task_id}'"
|
308
|
-
|
309
|
-
log "Check 'https://hud.iron.io/tq/projects/#{client.api.project_id}/jobs/#{retry_task_id}' for more info"
|
190
|
+
@cli.retry($*[0], params, options)
|
310
191
|
elsif command == 'log'
|
311
|
-
|
312
|
-
|
192
|
+
params = {}
|
193
|
+
options = {}
|
313
194
|
|
314
195
|
opts = OptionParser.new do |opts|
|
315
196
|
opts.banner = "usage: iron_worker log TASK_ID [OPTIONS]"
|
316
197
|
|
317
198
|
opts.on('-w', '--wait', 'wait for task') do |v|
|
318
|
-
wait = true
|
199
|
+
params[:wait] = true
|
319
200
|
end
|
320
201
|
|
321
202
|
common_opts(opts)
|
@@ -334,60 +215,20 @@ elsif command == 'log'
|
|
334
215
|
exit 1
|
335
216
|
end
|
336
217
|
|
337
|
-
|
338
|
-
|
339
|
-
client = create_client
|
340
|
-
|
341
|
-
log "#{LOG_GROUP}Getting log for task with id='#{task_id}'"
|
342
|
-
|
343
|
-
log = ''
|
344
|
-
|
345
|
-
if live
|
346
|
-
begin
|
347
|
-
log = client.tasks.log(task_id)
|
348
|
-
rescue IronCore::Error
|
349
|
-
end
|
350
|
-
else
|
351
|
-
if wait
|
352
|
-
client.tasks.wait_for(task_id)
|
353
|
-
end
|
354
|
-
|
355
|
-
log = client.tasks.log(task_id)
|
356
|
-
end
|
357
|
-
|
358
|
-
print log
|
359
|
-
|
360
|
-
if live
|
361
|
-
client.tasks.wait_for(task_id) do |task|
|
362
|
-
if task.status == 'running'
|
363
|
-
begin
|
364
|
-
next_log = client.tasks.log(task_id)
|
365
|
-
print next_log[log.length .. - 1]
|
366
|
-
log = next_log
|
367
|
-
rescue IronCore::Error
|
368
|
-
end
|
369
|
-
end
|
370
|
-
end
|
371
|
-
|
372
|
-
begin
|
373
|
-
next_log = client.tasks.log(task_id)
|
374
|
-
print next_log[log.length .. - 1]
|
375
|
-
rescue IronCore::Error
|
376
|
-
end
|
377
|
-
end
|
218
|
+
@cli.getlog($*[0], params, options)
|
378
219
|
elsif command == 'run'
|
379
|
-
|
380
|
-
|
220
|
+
params = {}
|
221
|
+
options = {}
|
381
222
|
|
382
223
|
opts = OptionParser.new do |opts|
|
383
224
|
opts.banner = "usage: iron_worker run CODE_PACKAGE_NAME_OR_PATH_TO_WORKERFILE [OPTIONS]"
|
384
225
|
|
385
226
|
opts.on('-p', '--payload PAYLOAD', String, 'payload to pass') do |v|
|
386
|
-
payload = v
|
227
|
+
params[:payload] = v
|
387
228
|
end
|
388
229
|
|
389
230
|
opts.on('-f', '--payload-file PAYLOAD_FILE', String, 'payload file to pass') do |v|
|
390
|
-
|
231
|
+
params[:payload] = File.read(v)
|
391
232
|
end
|
392
233
|
|
393
234
|
common_opts(opts)
|
@@ -406,20 +247,35 @@ elsif command == 'run'
|
|
406
247
|
exit 1
|
407
248
|
end
|
408
249
|
|
409
|
-
|
410
|
-
|
411
|
-
|
250
|
+
@cli.run($*[0], params, options)
|
251
|
+
elsif command == 'install'
|
252
|
+
params = {}
|
253
|
+
options = {}
|
412
254
|
|
413
|
-
|
255
|
+
opts = OptionParser.new do |opts|
|
256
|
+
opts.banner = 'usage: iron_worker install CODE_PACKAGE_NAME_OR_PATH_TO_WORKERFILE [OPTIONS]'
|
414
257
|
|
415
|
-
|
258
|
+
common_opts(opts)
|
259
|
+
end
|
416
260
|
|
417
|
-
|
261
|
+
begin
|
262
|
+
opts.parse!
|
263
|
+
rescue OptionParser::ParseError
|
264
|
+
puts $!.to_s
|
265
|
+
exit 1
|
266
|
+
end
|
418
267
|
|
419
|
-
|
268
|
+
unless $*.size == 1
|
269
|
+
puts 'Please specify code package name or path to workerfile'
|
270
|
+
puts opts
|
271
|
+
exit 1
|
272
|
+
end
|
420
273
|
|
421
|
-
|
274
|
+
@cli.install($*[0], params, options)
|
422
275
|
elsif command == 'webhook'
|
276
|
+
params = {}
|
277
|
+
options = {}
|
278
|
+
|
423
279
|
opts = OptionParser.new do |opts|
|
424
280
|
opts.banner = 'usage: iron_worker webhook CODE_PACKAGE_NAME [OPTIONS]'
|
425
281
|
|
@@ -439,139 +295,90 @@ elsif command == 'webhook'
|
|
439
295
|
exit 1
|
440
296
|
end
|
441
297
|
|
442
|
-
|
443
|
-
|
444
|
-
client = create_client
|
445
|
-
|
446
|
-
log "#{LOG_GROUP}Detecting webhook for code package with name='#{name}'"
|
447
|
-
log "Use POST to 'https://worker-aws-us-east-1.iron.io/2/projects/#{client.api.project_id}/tasks/webhook?code_name=#{name}&oauth=#{client.api.token}' to invoke worker via webhook"
|
298
|
+
@cli.webhook($*[0], params, options)
|
448
299
|
elsif command == 'info'
|
449
|
-
|
450
|
-
|
300
|
+
entities = ['code', 'task', 'schedule']
|
301
|
+
|
302
|
+
if $*.size == 0 || (not entities.include?($*[0]))
|
303
|
+
puts 'usage: iron_worker info ENTITY [OPTIONS]'
|
304
|
+
puts " ENTITY: #{entities.join(', ')}"
|
305
|
+
puts ' run iron_worker info ENTITY --help to get more information about each entity'
|
451
306
|
exit 1
|
452
307
|
end
|
453
308
|
|
454
|
-
entity
|
455
|
-
client = create_client
|
309
|
+
entity = $*.shift
|
456
310
|
|
457
311
|
if entity == 'code'
|
458
|
-
|
312
|
+
params = {}
|
313
|
+
options = {}
|
459
314
|
|
460
|
-
|
461
|
-
|
462
|
-
exit 1
|
463
|
-
end
|
315
|
+
opts = OptionParser.new do |opts|
|
316
|
+
opts.banner = "usage: iron_worker info code CODE_PACAKGE_NAME [OPTIONS]"
|
464
317
|
|
465
|
-
|
466
|
-
|
467
|
-
(<<EOL
|
468
|
-
#{LOG_GROUP}Code package '#{code.name}'
|
469
|
-
ID: #{code.id}
|
470
|
-
Created: #{created_at}
|
471
|
-
Last Modified: #{latest_change}
|
472
|
-
Revision: #{code.rev}
|
473
|
-
All Revisions: https://hud.iron.io/tq/projects/#{client.api.project_id}/code/#{code.id}
|
474
|
-
Tasks: https://hud.iron.io/tq/projects/#{client.api.project_id}/jobs/#{code.id}/activity
|
475
|
-
EOL
|
476
|
-
).lines.each{ |msg| log msg.chomp }
|
477
|
-
end
|
318
|
+
common_opts(opts)
|
319
|
+
end
|
478
320
|
|
479
|
-
if entity == 'task'
|
480
321
|
begin
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
# iron_core throws exception if id not found
|
486
|
-
IronCore::Logger.logger.level = prev_level
|
487
|
-
log "#{LOG_GROUP}Task with id #{id} not found"
|
488
|
-
exit(1)
|
489
|
-
ensure
|
490
|
-
IronCore::Logger.logger.level = prev_level
|
322
|
+
opts.parse!
|
323
|
+
rescue OptionParser::ParseError
|
324
|
+
puts $!.to_s
|
325
|
+
exit 1
|
491
326
|
end
|
492
327
|
|
493
|
-
|
494
|
-
|
495
|
-
|
328
|
+
unless $*.size == 1
|
329
|
+
puts 'Please specify code package name'
|
330
|
+
puts opts
|
331
|
+
exit 1
|
332
|
+
end
|
496
333
|
|
497
|
-
|
498
|
-
|
334
|
+
@cli.info_code($*[0], params, options)
|
335
|
+
elsif entity == 'task'
|
336
|
+
params = {}
|
337
|
+
options = {}
|
499
338
|
|
500
|
-
|
501
|
-
|
502
|
-
hours = total / (60 * 60)
|
339
|
+
opts = OptionParser.new do |opts|
|
340
|
+
opts.banner = "usage: iron_worker info task TASK_ID [OPTIONS]"
|
503
341
|
|
504
|
-
|
342
|
+
common_opts(opts)
|
505
343
|
end
|
506
344
|
|
507
|
-
log "#{LOG_GROUP}Task id #{id} found"
|
508
|
-
log "Code Package: '#{task.code_name}', rev #{task.code_rev}, download: https://hud.iron.io/tq/projects/#{client.api.project_id}/code/#{task.code_id}/download?hid=#{task.code_history_id}"
|
509
|
-
log " Status: #{task.status}"
|
510
|
-
log " Priority: #{task.priority}" if task.priority
|
511
|
-
log " Queued: #{queued}"
|
512
|
-
log " Started: #{started}" if started
|
513
|
-
log " Finished: #{finished}" if finished
|
514
|
-
log " Duration: #{duration}" if finished
|
515
|
-
log " Payload: #{task.payload}" unless task.payload == 'null'
|
516
|
-
log "Task Details: https://hud.iron.io/tq/projects/#{client.api.project_id}/jobs/#{task.id}"
|
517
|
-
end
|
518
|
-
|
519
|
-
if entity == 'schedule'
|
520
345
|
begin
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
# iron_core throws exception if id not found
|
526
|
-
IronCore::Logger.logger.level = prev_level
|
527
|
-
log "#{LOG_GROUP}Schedule with id #{id} not found"
|
528
|
-
exit(1)
|
529
|
-
ensure
|
530
|
-
IronCore::Logger.logger.level = prev_level
|
346
|
+
opts.parse!
|
347
|
+
rescue OptionParser::ParseError
|
348
|
+
puts $!.to_s
|
349
|
+
exit 1
|
531
350
|
end
|
532
351
|
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
log "#{LOG_GROUP}Schedule id #{id} found"
|
539
|
-
log " Code Name: #{schedule.code_name}"
|
540
|
-
log " Created: #{parse_time(schedule.created_at)}"
|
541
|
-
log " Message: #{schedule.msg}" if schedule.msg
|
542
|
-
log " Status: #{schedule.status}"
|
543
|
-
log " Start: #{start_at}" if start_at
|
544
|
-
log " End: #{end_at}" if end_at
|
545
|
-
log "Next Start: #{next_start}" if next_start
|
546
|
-
log " Run Count: #{schedule.run_count}" if schedule.run_count
|
547
|
-
log " Payload: #{schedule.payload}" unless schedule.payload == 'null'
|
548
|
-
log " Details: https://hud.iron.io/tq/projects/#{client.api.project_id}/scheduled_jobs/#{id}"
|
549
|
-
end
|
550
|
-
elsif command == 'install'
|
551
|
-
opts = OptionParser.new do |opts|
|
552
|
-
opts.banner = 'usage: iron_worker install CODE_PACKAGE_NAME_OR_PATH_TO_WORKERFILE [OPTIONS]'
|
553
|
-
|
554
|
-
common_opts(opts)
|
555
|
-
end
|
352
|
+
unless $*.size == 1
|
353
|
+
puts 'Please specify task id'
|
354
|
+
puts opts
|
355
|
+
exit 1
|
356
|
+
end
|
556
357
|
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
exit 1
|
562
|
-
end
|
358
|
+
@cli.info_task($*[0], params, options)
|
359
|
+
elsif entity == 'schedule'
|
360
|
+
params = {}
|
361
|
+
options = {}
|
563
362
|
|
564
|
-
|
565
|
-
|
566
|
-
puts opts
|
567
|
-
exit 1
|
568
|
-
end
|
363
|
+
opts = OptionParser.new do |opts|
|
364
|
+
opts.banner = "usage: iron_worker info schedule SCHEDULE_ID [OPTIONS]"
|
569
365
|
|
570
|
-
|
366
|
+
common_opts(opts)
|
367
|
+
end
|
571
368
|
|
572
|
-
|
369
|
+
begin
|
370
|
+
opts.parse!
|
371
|
+
rescue OptionParser::ParseError
|
372
|
+
puts $!.to_s
|
373
|
+
exit 1
|
374
|
+
end
|
573
375
|
|
574
|
-
|
376
|
+
unless $*.size == 1
|
377
|
+
puts 'Please specify schedule id'
|
378
|
+
puts opts
|
379
|
+
exit 1
|
380
|
+
end
|
575
381
|
|
576
|
-
|
382
|
+
@cli.info_schedule($*[0], params, options)
|
383
|
+
end
|
577
384
|
end
|