servicesnapshot 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/servicesnapshot +14 -2
- data/lib/Snapshot/Beanstalk.rb +13 -2
- data/lib/helper_functions.rb +18 -0
- metadata +1 -1
data/bin/servicesnapshot
CHANGED
@@ -10,9 +10,21 @@ require "Snapshot/Beanstalk"
|
|
10
10
|
#Don't buffer stdout
|
11
11
|
$stdout.sync = true
|
12
12
|
|
13
|
-
|
13
|
+
if ARGV.length != 1 then
|
14
|
+
puts "Available dsl's"
|
15
|
+
puts "==============="
|
16
|
+
Dir.glob("./*.dsl").each do |dslFileName|
|
17
|
+
puts File.basename(dslFileName)
|
18
|
+
end
|
19
|
+
Dir.glob("#{ENV['HOME']}/servicesnapshot/*.dsl").each do |dslFileName|
|
20
|
+
puts File.basename(dslFileName)
|
21
|
+
end
|
22
|
+
puts "==============="
|
23
|
+
|
24
|
+
abort( "Usage: servicesnapshot <path to dsl>" ) if ARGV.length != 1
|
25
|
+
end
|
14
26
|
|
15
|
-
dslName = ARGV[0]
|
27
|
+
dslName = getFileName(ARGV[0])
|
16
28
|
|
17
29
|
#Need to remove file name extension
|
18
30
|
ENV["APP_NAME"] = File.basename( dslName ) if ENV["APP_NAME"].nil?
|
data/lib/Snapshot/Beanstalk.rb
CHANGED
@@ -46,7 +46,7 @@ def beanstalk( params )
|
|
46
46
|
queues = get_param( params, :queues, usage )
|
47
47
|
rescue ParameterMissingError=>e
|
48
48
|
end
|
49
|
-
|
49
|
+
queues = [queues] if queues.class.name == "String"
|
50
50
|
|
51
51
|
localPort, gateway = open_gateway( user, host )
|
52
52
|
|
@@ -56,9 +56,20 @@ def beanstalk( params )
|
|
56
56
|
log "Connect to remote beanstalk", true
|
57
57
|
beanstalk = Beanstalk::Pool.new([destinationUrl])
|
58
58
|
|
59
|
+
hash = Hash.new
|
59
60
|
beanstalk.list_tubes[destinationUrl].each do |name|
|
60
61
|
tubeStats = beanstalk.stats_tube(name)
|
61
|
-
|
62
|
+
hash[name] = tubeStats["current-jobs-ready"].to_s
|
63
|
+
end
|
64
|
+
|
65
|
+
if queues.nil? then
|
66
|
+
hash.each do |k,v|
|
67
|
+
list << "#{k}(#{v})"
|
68
|
+
end
|
69
|
+
else
|
70
|
+
queues.each do |k|
|
71
|
+
list << "#{k}(#{hash[k]})"
|
72
|
+
end
|
62
73
|
end
|
63
74
|
|
64
75
|
title = "beanstalk: #{user}@#{host} #{queues}"
|
data/lib/helper_functions.rb
CHANGED
@@ -54,3 +54,21 @@ end
|
|
54
54
|
def formatOutput( title, content )
|
55
55
|
puts "\n===> #{title} <===\n#{content}"
|
56
56
|
end
|
57
|
+
|
58
|
+
def getDslDirectory
|
59
|
+
return "#{ENV['HOME']}/servicesnapshot"
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
def getFileName( path )
|
64
|
+
path = "#{path}.dsl" if File.extname(path) == ""
|
65
|
+
|
66
|
+
p = path
|
67
|
+
return p if File.exists?( p )
|
68
|
+
|
69
|
+
p = "#{getDslDirectory}/#{path}"
|
70
|
+
return p if File.exists?( p )
|
71
|
+
|
72
|
+
abort( "Could not find the dsl you passed in, #{path}" )
|
73
|
+
end
|
74
|
+
|