tailog 0.5.9 → 0.6.0
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.
- checksums.yaml +4 -4
- data/app/views/script/index.erb +94 -24
- data/app/views/script/ruby.erb +13 -4
- data/lib/tailog/ext/irb.rb +4 -0
- data/lib/tailog/version.rb +1 -1
- data/lib/tailog.rb +19 -5
- metadata +2 -3
- data/app/views/script/ruby_debug.erb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c4a061b770009df2e91f93ac5b5dad228187bde
|
4
|
+
data.tar.gz: 46d65f82419ac331348bdcb5025e6d0c0bd8de55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 257905134ec95342d84b7521980e84cd9d428f520dd50ac932f09371c3359d90257f83a6a3b912c1217b1459effcec519120f8563c543bbdee9bc5909daacd63
|
7
|
+
data.tar.gz: cd734694966ded697fa5c4a3cd1492f448ec7b6ace86d7048c2dfd2bab1476f798afb7d3706482e27e2375c73d7514f1c966d35c7b554e5d7c9f83e64a68af72
|
data/app/views/script/index.erb
CHANGED
@@ -5,9 +5,9 @@
|
|
5
5
|
<div class="pull-right">
|
6
6
|
<select name="type" class="form-control" id="mode">
|
7
7
|
<option value="ruby">Ruby</option>
|
8
|
-
<option value="ruby_debug">Ruby (Debug Mode)</option>
|
9
8
|
<option value="bash">Bash</option>
|
10
9
|
</select>
|
10
|
+
<button id="broadcast-button" type="submit" class="btn btn-danger">Broadcast</button>
|
11
11
|
<button id="submit-button" type="submit" class="btn btn-primary">Submit</button>
|
12
12
|
</div>
|
13
13
|
<div>
|
@@ -35,9 +35,8 @@
|
|
35
35
|
lineNumbers: true
|
36
36
|
});
|
37
37
|
|
38
|
-
ModeMap = {
|
38
|
+
var ModeMap = {
|
39
39
|
ruby: "ruby",
|
40
|
-
ruby_debug: "ruby",
|
41
40
|
bash: "shell"
|
42
41
|
};
|
43
42
|
|
@@ -45,30 +44,101 @@
|
|
45
44
|
editor.setOption("mode", ModeMap[$(this).val()]);
|
46
45
|
});
|
47
46
|
|
47
|
+
var $content = $("#content"),
|
48
|
+
$script = $("#script");
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
.append('<span class="text-danger">Oops! Something went wrong, please try again later!</span>')
|
61
|
-
},
|
62
|
-
success: function(json) {
|
63
|
-
try {
|
64
|
-
var data = JSON.parse(json);
|
50
|
+
$("#submit-button").click(function(event) {
|
51
|
+
event.preventDefault();
|
52
|
+
editor.save();
|
53
|
+
|
54
|
+
$script.ajaxSubmit({
|
55
|
+
beforeSend: function() {
|
56
|
+
$content
|
57
|
+
.html("<hr/>")
|
58
|
+
.append('<span class="text-info">Loading...</span>');
|
59
|
+
},
|
60
|
+
error: function() {
|
65
61
|
$content
|
66
62
|
.html("<hr/>")
|
67
|
-
.append('<span class="text-
|
68
|
-
|
69
|
-
|
70
|
-
|
63
|
+
.append('<span class="text-danger">Oops! Something went wrong, please try again later!</span>');
|
64
|
+
},
|
65
|
+
success: function(json) {
|
66
|
+
try {
|
67
|
+
var data = JSON.parse(json);
|
68
|
+
$content
|
69
|
+
.html("<hr/>")
|
70
|
+
.append('<span class="text-info">' + data.server_hostname + " - " + data.process_uuid + "</span>")
|
71
|
+
.append(ansi_up.ansi_to_html(data.content));
|
72
|
+
} catch (error) {
|
73
|
+
console.error(error)
|
74
|
+
}
|
75
|
+
}
|
76
|
+
});
|
77
|
+
});
|
78
|
+
|
79
|
+
$("#broadcast-button").click(function(event) {
|
80
|
+
event.preventDefault();
|
81
|
+
editor.save();
|
82
|
+
|
83
|
+
$content
|
84
|
+
.html("<hr/>")
|
85
|
+
.append('<div class="progress"><div class="progress-bar progress-bar-success progress-bar-striped active" role="progressbar" style="width: 0%"><span class="progress-bar-indicator">0 / 1 Requests, 0 Instances (0%)</span></div></div>');
|
86
|
+
var $progressBar = $(".progress-bar"),
|
87
|
+
$indicator = $(".progress-bar-indicator");
|
88
|
+
|
89
|
+
var MaxCurrent = 10;
|
90
|
+
var discovered = [],
|
91
|
+
totalEstimate = 1,
|
92
|
+
currentTries = 0,
|
93
|
+
concurrent = 0;
|
94
|
+
|
95
|
+
var ajaxInterval = setInterval(function() {
|
96
|
+
if (currentTries < totalEstimate) {
|
97
|
+
if (concurrent < MaxCurrent) {
|
98
|
+
$script.ajaxSubmit({
|
99
|
+
data: {
|
100
|
+
broadcast: true,
|
101
|
+
discovered_instances: discovered
|
102
|
+
},
|
103
|
+
beforeSend: function() {
|
104
|
+
currentTries += 1;
|
105
|
+
concurrent += 1;
|
106
|
+
},
|
107
|
+
error: function() {
|
108
|
+
$content
|
109
|
+
.html("<hr/>")
|
110
|
+
.append('<span class="text-danger">Oops! Something went wrong, please try again later!</span>')
|
111
|
+
},
|
112
|
+
success: function(json) {
|
113
|
+
try {
|
114
|
+
var data = JSON.parse(json);
|
115
|
+
|
116
|
+
var instanceId = data.instance_id;
|
117
|
+
if (discovered.indexOf(instanceId) < 0) {
|
118
|
+
totalEstimate += currentTries * 2 + 2;
|
119
|
+
discovered.push(instanceId);
|
120
|
+
|
121
|
+
$content
|
122
|
+
.append('<hr/><span class="text-info">' + data.server_hostname + " - " + data.process_uuid + "</span>")
|
123
|
+
.append(ansi_up.ansi_to_html(data.content));
|
124
|
+
}
|
125
|
+
|
126
|
+
var percent = +parseFloat(currentTries / totalEstimate * 100).toFixed(2);
|
127
|
+
$indicator.text(currentTries + " / " + totalEstimate + " Requests, " + discovered.length + " Instances (" + percent + "%)");
|
128
|
+
$progressBar.width(percent + "%");
|
129
|
+
|
130
|
+
} catch (error) {
|
131
|
+
console.error(error)
|
132
|
+
}
|
133
|
+
},
|
134
|
+
complete: function() {
|
135
|
+
concurrent -= 1;
|
136
|
+
}
|
137
|
+
});
|
138
|
+
}
|
139
|
+
} else {
|
140
|
+
clearInterval(ajaxInterval);
|
71
141
|
}
|
72
|
-
}
|
142
|
+
}, 100);
|
73
143
|
});
|
74
144
|
</script>
|
data/app/views/script/ruby.erb
CHANGED
@@ -1,10 +1,19 @@
|
|
1
1
|
<% begin %>
|
2
|
-
<%
|
2
|
+
<% irb = IRB::Irb.new nil, StringInputMethod.new(script + "\nexit\n") %>
|
3
|
+
<% IRB.conf[:MAIN_CONTEXT] = irb.context %>
|
4
|
+
<% IRB.conf[:OUTPUT] = [] %>
|
3
5
|
|
4
6
|
<% begin %>
|
5
|
-
<%
|
6
|
-
<%
|
7
|
-
|
7
|
+
<% irb.eval_input %>
|
8
|
+
<% IRB.Output.each do |key, line| %>
|
9
|
+
<% case key
|
10
|
+
when :stdin %>
|
11
|
+
<p class="text-info"><%= h line %></p>
|
12
|
+
<% when :stdout %>
|
13
|
+
<p><%= h line %></p>
|
14
|
+
<% when :stderr %>
|
15
|
+
<p class="text-danger"><%= h line %></p>
|
16
|
+
<% end %>
|
8
17
|
<% end %>
|
9
18
|
<% rescue => error %>
|
10
19
|
<p class="text-danger"><%= h error.class %>: <%= h error.message %></p>
|
data/lib/tailog/ext/irb.rb
CHANGED
data/lib/tailog/version.rb
CHANGED
data/lib/tailog.rb
CHANGED
@@ -20,6 +20,10 @@ module Tailog
|
|
20
20
|
def server_hostname
|
21
21
|
@server_hostname ||= Socket.gethostname
|
22
22
|
end
|
23
|
+
|
24
|
+
def process_uuid
|
25
|
+
@process_uuid ||= SecureRandom.uuid
|
26
|
+
end
|
23
27
|
end
|
24
28
|
|
25
29
|
self.log_path = File.expand_path("log", Dir.pwd)
|
@@ -62,6 +66,7 @@ module Tailog
|
|
62
66
|
|
63
67
|
{
|
64
68
|
server_hostname: Tailog.server_hostname,
|
69
|
+
process_uuid: Tailog.process_uuid,
|
65
70
|
file_size: file_size,
|
66
71
|
content: content
|
67
72
|
}.to_json
|
@@ -76,12 +81,21 @@ module Tailog
|
|
76
81
|
end
|
77
82
|
|
78
83
|
post '/script' do
|
79
|
-
|
80
|
-
|
81
|
-
{
|
84
|
+
result = {
|
82
85
|
server_hostname: Tailog.server_hostname,
|
83
|
-
|
84
|
-
}
|
86
|
+
process_uuid: Tailog.process_uuid
|
87
|
+
}
|
88
|
+
|
89
|
+
ignore_content = false
|
90
|
+
if params[:broadcast]
|
91
|
+
instance_id = result[:instance_id] = params[:type] == "bash" ? Tailog.server_hostname : Tailog.process_uuid
|
92
|
+
discovered_instances = params[:discovered_instances] || []
|
93
|
+
ignore_content = true if discovered_instances.include? instance_id
|
94
|
+
end
|
95
|
+
|
96
|
+
result[:content] = erb :"script/#{params[:type]}", locals: { script: params[:script] }, layout: false unless ignore_content
|
97
|
+
|
98
|
+
result.to_json
|
85
99
|
end
|
86
100
|
end
|
87
101
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tailog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bbtfr
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -91,7 +91,6 @@ files:
|
|
91
91
|
- app/views/script/bash.erb
|
92
92
|
- app/views/script/index.erb
|
93
93
|
- app/views/script/ruby.erb
|
94
|
-
- app/views/script/ruby_debug.erb
|
95
94
|
- bin/console
|
96
95
|
- bin/setup
|
97
96
|
- lib/tailog.rb
|
@@ -1,28 +0,0 @@
|
|
1
|
-
<% begin %>
|
2
|
-
<% irb = IRB::Irb.new nil, StringInputMethod.new(script + "\n") %>
|
3
|
-
<% IRB.conf[:MAIN_CONTEXT] = irb.context %>
|
4
|
-
<% IRB.conf[:OUTPUT] = [] %>
|
5
|
-
|
6
|
-
<% begin %>
|
7
|
-
<% irb.eval_input %>
|
8
|
-
<% IRB.Output.each do |key, line| %>
|
9
|
-
<% case key
|
10
|
-
when :stdin %>
|
11
|
-
<p class="text-info"><%= h line %></p>
|
12
|
-
<% when :stdout %>
|
13
|
-
<p><%= h line %></p>
|
14
|
-
<% when :stderr %>
|
15
|
-
<p class="text-danger"><%= h line %></p>
|
16
|
-
<% end %>
|
17
|
-
<% end %>
|
18
|
-
<% rescue => error %>
|
19
|
-
<p class="text-danger"><%= h error.class %>: <%= h error.message %></p>
|
20
|
-
<% error.backtrace.each do |backtrace| %>
|
21
|
-
<p class="text-danger"> <%= h backtrace %></p>
|
22
|
-
<% end %>
|
23
|
-
<% end %>
|
24
|
-
|
25
|
-
<% rescue => error %>
|
26
|
-
<%= erb :error, locals: { error: error }, layout: false %>
|
27
|
-
<% end %>
|
28
|
-
|