taq-traquitana 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/deploy.rb +35 -6
- metadata +1 -1
data/lib/deploy.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
module Traquitana
|
2
2
|
class Deploy
|
3
|
-
TRAQ_VERSION="0.0.
|
3
|
+
TRAQ_VERSION="0.0.5"
|
4
4
|
|
5
5
|
def initialize
|
6
|
-
@config
|
6
|
+
@config = Traquitana::Config.instance
|
7
|
+
@progress = -1
|
7
8
|
end
|
8
9
|
|
9
10
|
def section_msg(msg)
|
@@ -26,6 +27,34 @@ module Traquitana
|
|
26
27
|
exit 1
|
27
28
|
end
|
28
29
|
|
30
|
+
def show_bar(name,sent,total)
|
31
|
+
bt, bp = 20, 5
|
32
|
+
return if sent<=0
|
33
|
+
|
34
|
+
prop = sent > 0 ? ((100/(total/sent.to_f))/bp).to_i : 0
|
35
|
+
return if prop<=0
|
36
|
+
|
37
|
+
if prop != @progress
|
38
|
+
bar = Array.new(bt,"-")
|
39
|
+
bar[0...prop] = Array.new(prop,"*")
|
40
|
+
name = File.basename(name).ljust(20)
|
41
|
+
STDOUT.print "Sending #{name} #{(prop*bp).to_s.rjust(3)}% : #{bar.join}\r"
|
42
|
+
STDOUT.flush
|
43
|
+
@progress = prop
|
44
|
+
end
|
45
|
+
if sent==total
|
46
|
+
puts "\n#{name.strip} sent.\n"
|
47
|
+
@progress = -1
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def upload(scp,from,to)
|
52
|
+
puts " "
|
53
|
+
scp.upload!(from,to) do |ch,name,sent,total|
|
54
|
+
show_bar(name,sent,total)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
29
58
|
def run
|
30
59
|
if !File.exist?(@config.config)
|
31
60
|
STDERR.puts "No config file (#{@config.config}) found."
|
@@ -94,10 +123,10 @@ module Traquitana
|
|
94
123
|
end
|
95
124
|
|
96
125
|
Net::SCP.start(@config.host,@config.user,options) do |scp|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
126
|
+
upload(scp,"#{File.dirname(File.expand_path(__FILE__))}/../config/proc.sh","#{@config.directory}/traq/proc.sh")
|
127
|
+
upload(scp,"#{File.dirname(File.expand_path(__FILE__))}/../config/#{@config.server}.sh","#{@config.directory}/traq/server.sh")
|
128
|
+
upload(scp,all_list_file,"#{@config.directory}/traq/#{all_list_file}")
|
129
|
+
upload(scp,all_list_zip ,"#{@config.directory}/traq/#{all_list_zip}")
|
101
130
|
end
|
102
131
|
section_msg("Running processes on the remote server")
|
103
132
|
|