singularity-cli 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/singularity +18 -1
- data/lib/singularity.rb +15 -38
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b11bac3f0e26dcf4d6259d2da6fc587fc901c9e0
|
4
|
+
data.tar.gz: 8880e2d2a6c9d95f36ccbc0a3ac5241462ae6063
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 729a5968fc1b06c7479d56fb99ec64057f301f8c0ac1c8daeb262a6db103b5b96d49f7929aa7a4aff935cbbbd165d780ffdb080bd11e06e3ab8c634e048a5e1f
|
7
|
+
data.tar.gz: 5b212f74c1e911bfa46133c7db4819d30bef1d6d3ca841bec3e519b0a3bb93c96a425f0217d5708f6d6c6d9c299257383dd9452e797f57f0a5c49193f7d66906
|
data/bin/singularity
CHANGED
@@ -5,10 +5,27 @@ require 'singularity'
|
|
5
5
|
ARGV << '--help' if ARGV.empty?
|
6
6
|
|
7
7
|
def print_usage
|
8
|
-
puts
|
8
|
+
puts
|
9
9
|
exit
|
10
10
|
end
|
11
11
|
|
12
|
+
def print_usage
|
13
|
+
puts <<END
|
14
|
+
# Usage:
|
15
|
+
# singularity deploy <uri> <file.json> <release>
|
16
|
+
# - deploy singularity job
|
17
|
+
# singularity delete <uri> <file.json>
|
18
|
+
# - delete singularity deploy
|
19
|
+
# singularity run <commands>
|
20
|
+
# - start new box in singularity and run <commands>
|
21
|
+
# (do this from the base project folder of the box you wish to start)
|
22
|
+
# singularity runx <commands>
|
23
|
+
# - same as "singularity run" without use of /sbin/my_init
|
24
|
+
# singularity ssh
|
25
|
+
# - start new box in singularity and SSH into it
|
26
|
+
END
|
27
|
+
end
|
28
|
+
|
12
29
|
action = ARGV[0]
|
13
30
|
uri = ARGV[1]
|
14
31
|
file = ARGV[2]
|
data/lib/singularity.rb
CHANGED
@@ -79,10 +79,10 @@ module Singularity
|
|
79
79
|
|
80
80
|
class Runner
|
81
81
|
def initialize(script)
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
82
|
+
if !File.file?("mesos-deploy.yml") or !File.file?(".mescal.json")
|
83
|
+
puts "Please do this command from a project directory (where mesos-deploy.yml and .mescal.json exist)"
|
84
|
+
end
|
85
|
+
|
86
86
|
@script = script
|
87
87
|
# read .mescal.json for ssh command, image, release number, cpus, mem
|
88
88
|
@configData = JSON.parse(ERB.new(open(File.join(Dir.pwd, ".mescal.json")).read).result(Request.new.get_binding))
|
@@ -205,51 +205,28 @@ module Singularity
|
|
205
205
|
# output STDOUT / STDERR to shell
|
206
206
|
@stdoutOffset = 0
|
207
207
|
@stderrOffset = 0
|
208
|
-
@lastOutLine = ''
|
209
|
-
@lastErrLine = ''
|
210
208
|
begin
|
211
209
|
# get most recent task state
|
210
|
+
# need to wait for "task_running" before we can ask for STDOUT/STDERR
|
212
211
|
@taskState = JSON.parse(RestClient.get "#{@uri}/api/history/task/#{@thisTask['taskId']['id']}")
|
213
212
|
@taskState["taskUpdates"].each do |update|
|
214
213
|
@taskState = update['taskState']
|
215
214
|
end
|
216
|
-
|
217
|
-
# need to wait for "task_running" before we can ask for STDOUT/STDERR
|
218
215
|
if @taskState == "TASK_RUNNING"
|
216
|
+
# print stdout
|
219
217
|
@stdout = JSON.parse(RestClient.get "#{@uri}/api/sandbox/#{@thisTask['taskId']['id']}/read", {params: {path: "stdout", length: 30000, offset: @stdoutOffset}})['data']
|
220
|
-
|
221
|
-
@stdout
|
222
|
-
|
223
|
-
|
224
|
-
@stdout.shift
|
225
|
-
end
|
226
|
-
if !@stdout.empty?
|
227
|
-
if @stdout[0].length > 0
|
228
|
-
@stdout.each do |i|
|
229
|
-
puts i.light_cyan
|
230
|
-
end
|
231
|
-
end
|
232
|
-
end
|
233
|
-
@lastOutLine = @stdout.last
|
218
|
+
outLength = @stdout.bytes.to_a.size
|
219
|
+
if @stdout.length > 0
|
220
|
+
print @stdout.light_cyan
|
221
|
+
@stdoutOffset += outLength
|
234
222
|
end
|
235
|
-
|
223
|
+
# print stderr
|
236
224
|
@stderr = JSON.parse(RestClient.get "#{@uri}/api/sandbox/#{@thisTask['taskId']['id']}/read", {params: {path: "stderr", length: 30000, offset: @stderrOffset}})['data']
|
237
|
-
|
238
|
-
@stderr
|
239
|
-
|
240
|
-
|
241
|
-
@stderr.shift
|
242
|
-
end
|
243
|
-
if !@stderr.empty?
|
244
|
-
if @stderr[0].length > 0
|
245
|
-
@stderr.each do |i|
|
246
|
-
puts i.light_magenta
|
247
|
-
end
|
248
|
-
end
|
249
|
-
end
|
250
|
-
@lastErrLine = @stderr.last
|
225
|
+
errLength = @stderr.bytes.to_a.size
|
226
|
+
if @stderr.length > 0
|
227
|
+
print @stderr.light_magenta
|
228
|
+
@stderrOffset += errLength
|
251
229
|
end
|
252
|
-
|
253
230
|
end
|
254
231
|
end until @taskState == "TASK_FINISHED"
|
255
232
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: singularity-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Travis Webb
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-10-
|
12
|
+
date: 2016-10-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|