singularity-cli 0.3.1 → 0.3.2

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/singularity +18 -1
  3. data/lib/singularity.rb +15 -38
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad0f8767080ab7ba91d8a934f7db17ebd2fa23e4
4
- data.tar.gz: 41704c0d0db1765d77bd86fa38d7c79cdc2eb132
3
+ metadata.gz: b11bac3f0e26dcf4d6259d2da6fc587fc901c9e0
4
+ data.tar.gz: 8880e2d2a6c9d95f36ccbc0a3ac5241462ae6063
5
5
  SHA512:
6
- metadata.gz: 90b4cd647f164706d0fb3704cada223c00e63d47ecff5ee944f0cc5dfb82a86f277194ad9d46ee79fcc1b1f999af9db8ad8e61fec6af3d201dd592f15c11d48d
7
- data.tar.gz: 9db0a3293d747a622c0980160e2d1334871d49f4621cf07cbe98f661cf16a649dd713ead2d3a14f40f86ed3f4877f2e5ac8c9c727ad4d468c1b0395d337d6698
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 "Usage:\n\tsingularity delete <uri> <file.json>\n\tsingularity deploy <uri> <file.json> <release>\n\tsingularity run <uri> <file.json> <release> <script>"
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
- # TODO
84
- # check to see that .mescal.json and mesos-deploy.yml exist
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
- @stdoutOffset += @stdout.length
221
- @stdout = @stdout.split("\n")
222
- if @stdout.any?
223
- if @lastOutLine.include? @stdout[0]
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
- @stderrOffset += @stderr.length
238
- @stderr = @stderr.split("\n")
239
- if @stderr.any?
240
- if @lastErrLine.include? @stderr[0]
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.1
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-03 00:00:00.000000000 Z
12
+ date: 2016-10-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client