resque-telework 0.3.0 → 0.3.1
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.
data/README.md
CHANGED
@@ -22,6 +22,17 @@ Note that currently (Telework 0.3), the daemon process is included in the main a
|
|
22
22
|
|
23
23
|
Telework has been successfully used in production at Entelo for more that a year with up to 10 servers.
|
24
24
|
|
25
|
+
Gems
|
26
|
+
----
|
27
|
+
|
28
|
+
Version 0.3.1
|
29
|
+
* Host aliases and comments (aliases come handy when hostnames cannot be chosen or changing them is too cumbersome - AWS comes to mind)
|
30
|
+
|
31
|
+
Version 0.3.0
|
32
|
+
* Auto mode for workers
|
33
|
+
* Updated window layout
|
34
|
+
|
35
|
+
|
25
36
|
Overview of the WebUI
|
26
37
|
---------------------
|
27
38
|
|
@@ -22,6 +22,14 @@ module Resque
|
|
22
22
|
def hosts_key # Set
|
23
23
|
"#{key_prefix}:hosts"
|
24
24
|
end
|
25
|
+
|
26
|
+
def aliases_key # Hash
|
27
|
+
"#{key_prefix}:aliases"
|
28
|
+
end
|
29
|
+
|
30
|
+
def comments_key # Hash
|
31
|
+
"#{key_prefix}:comments"
|
32
|
+
end
|
25
33
|
|
26
34
|
def revisions_key( h ) # List
|
27
35
|
"#{key_prefix}:host:#{h}:revisions"
|
@@ -98,7 +106,7 @@ module Resque
|
|
98
106
|
Resque.redis.set(last_seen_key( @HOST ), t)
|
99
107
|
end
|
100
108
|
|
101
|
-
def register_revision( h, rev, lim=
|
109
|
+
def register_revision( h, rev, lim=10 )
|
102
110
|
k= revisions_key(h)
|
103
111
|
Resque.redis.ltrim(k, 0, lim-1)
|
104
112
|
rem= []
|
@@ -127,7 +135,23 @@ module Resque
|
|
127
135
|
def hosts_add( h )
|
128
136
|
Resque.redis.sadd(hosts_key, h)
|
129
137
|
end
|
130
|
-
|
138
|
+
|
139
|
+
def aliases_add( h, a )
|
140
|
+
Resque.redis.hset( aliases_key, h, a ) unless Resque.redis.hvals( aliases_key ).include?( a )
|
141
|
+
end
|
142
|
+
|
143
|
+
def comments_add( h, a )
|
144
|
+
Resque.redis.hset( comments_key, h, a )
|
145
|
+
end
|
146
|
+
|
147
|
+
def aliases_rem( h )
|
148
|
+
Resque.redis.hdel( aliases_key, h )
|
149
|
+
end
|
150
|
+
|
151
|
+
def comments_rem( h )
|
152
|
+
Resque.redis.hdel( comments_key, h )
|
153
|
+
end
|
154
|
+
|
131
155
|
def revisions_add( h, v )
|
132
156
|
hosts_add(h)
|
133
157
|
k= revisions_key(h)
|
@@ -336,6 +360,15 @@ module Resque
|
|
336
360
|
Resque.redis.smembers(hosts_key)
|
337
361
|
end
|
338
362
|
|
363
|
+
def aliases( h )
|
364
|
+
a= Resque.redis.hget( aliases_key, h )
|
365
|
+
a.blank? ? h : a
|
366
|
+
end
|
367
|
+
|
368
|
+
def comments( h )
|
369
|
+
Resque.redis.hget( comments_key, h )
|
370
|
+
end
|
371
|
+
|
339
372
|
def revisions( h, lim=30 )
|
340
373
|
k= revisions_key(h)
|
341
374
|
Resque.redis.ltrim(k, 0, lim-1)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<h1>Host <%= @host %></h1>
|
2
|
+
|
3
|
+
<form style="margin:0px;float:center;" id="hostm" name="hostm" method="post" action="/resque/telework_mod_host/<%= @host %>" >
|
4
|
+
<table>
|
5
|
+
<tr><th>Parameter</th><th>Value</th><th>Description</th>
|
6
|
+
<tr><td>Hostname</td><td><%= @host %></td><td></td></tr>
|
7
|
+
<tr><td>Alias</td><td><% a= redis.aliases(@host) %><input id="alias" name="alias" size=60 type="text" value="<%= a==@host || a.blank? ? "" : "#{a}" %>" /></td><td>Alias used in telework</td></tr>
|
8
|
+
<tr><td>Comment</td><td><input id="comment" name="comment" size=60 type="text" value="<%= redis.comments(@host) %>" /></td><td>User-defined comment</td></tr>
|
9
|
+
</table>
|
10
|
+
<input type="submit" value= "Save" />
|
11
|
+
</form>
|
@@ -103,6 +103,8 @@ $(document).ready(function() {
|
|
103
103
|
<br>
|
104
104
|
<% end %>
|
105
105
|
|
106
|
+
<% hosts= redis.hosts %>
|
107
|
+
|
106
108
|
<% if @scheduling %>
|
107
109
|
|
108
110
|
<h1>Starting Workers</h1>
|
@@ -112,7 +114,7 @@ $(document).ready(function() {
|
|
112
114
|
<div class="control_panel sub_header">
|
113
115
|
<form id="startform" name="startform" method="post" action="/resque/telework/start_task" >
|
114
116
|
<span class="host_filter">
|
115
|
-
Host: <%=
|
117
|
+
Host: <%= generic_filter_with_dis("host_filter", "h", hosts.zip( hosts.map{ |h| redis.aliases(h) } ),
|
116
118
|
"onchange=\"javascript: hostlist(this.options[this.selectedIndex].value);\"") %>
|
117
119
|
</span>
|
118
120
|
<span class="queue_filter">
|
@@ -151,7 +153,7 @@ $(document).ready(function() {
|
|
151
153
|
<h1>Hosts, Revisions, Tasks and Workers</h1>
|
152
154
|
<form id="stopping_all" name="stopping_all" method="post" action="/resque/telework/stop_all">
|
153
155
|
<%= generic_filter("mode_filter", "m", ["Stop", "Kill"]) %>
|
154
|
-
all workers on host <%=
|
156
|
+
all workers on host <%= generic_filter_with_dis("host_filter", "h", hosts.zip( hosts.map{ |h| redis.aliases(h) } ) << ["[All hosts]", "[All hosts]"]) %>
|
155
157
|
<span class="stopping_all_submit"><input type="submit" value="Go"/></span>
|
156
158
|
</form></br>
|
157
159
|
<table>
|
@@ -163,9 +165,12 @@ $(document).ready(function() {
|
|
163
165
|
</tr>
|
164
166
|
<% for host, status, info in redis.daemons_state %>
|
165
167
|
<tr>
|
166
|
-
<td><center
|
168
|
+
<td><center><% ahost = redis.aliases(host) %>
|
169
|
+
<a href=<%= "/resque/telework/host/#{host}" %> title="<%= "#{host}\n#{redis.comments(host)}" %>" >
|
170
|
+
<% if ahost!=host %><%= ahost %><% else %>
|
171
|
+
<%= host %><% end %></a>
|
167
172
|
<% if 'Alive'==status && info['cpu_load_1mins'] %>
|
168
|
-
<br
|
173
|
+
<br/><%= "(%.2f%% cpu)" % (100*info['cpu_load_1mins']) %></center>
|
169
174
|
<% end %>
|
170
175
|
</td>
|
171
176
|
<% if 'Alive'==status %>
|
@@ -256,7 +261,7 @@ $(document).ready(function() {
|
|
256
261
|
</br>
|
257
262
|
<form id="stopping_all" name="stopping_all" method="post" action="/resque/telework/stop_all">
|
258
263
|
<%= generic_filter("mode_filter", "m", ["Stop", "Kill"]) %>
|
259
|
-
|
264
|
+
all workers on host <%= generic_filter_with_dis("host_filter", "h", hosts.zip( hosts.map{ |h| redis.aliases(h) } ) << ["[All hosts]", "[All hosts]"]) %>
|
260
265
|
<span class="stopping_all_submit"><input type="submit" value="Go"/></span>
|
261
266
|
</form></br></br>
|
262
267
|
|
@@ -30,7 +30,6 @@ module Resque
|
|
30
30
|
end
|
31
31
|
def generic_filter(id, name, list, more= "")
|
32
32
|
html = "<select id=\"#{id}\" name=\"#{name}\" #{more}>"
|
33
|
-
#html += "<option value=\"\">-</option>"
|
34
33
|
value= list[0]
|
35
34
|
list.each do |k|
|
36
35
|
selected = k == value ? 'selected="selected"' : ''
|
@@ -38,6 +37,15 @@ module Resque
|
|
38
37
|
end
|
39
38
|
html += "</select>"
|
40
39
|
end
|
40
|
+
def generic_filter_with_dis(id, name, list, more= "")
|
41
|
+
html = "<select id=\"#{id}\" name=\"#{name}\" #{more}>"
|
42
|
+
value= list[0][0]
|
43
|
+
list.each do |k,dis|
|
44
|
+
selected = k == value ? 'selected="selected"' : ''
|
45
|
+
html += "<option #{selected} value=\"#{k}\">#{dis}</option>"
|
46
|
+
end
|
47
|
+
html += "</select>"
|
48
|
+
end
|
41
49
|
def task_default
|
42
50
|
{ 'auto_max_waiting_job_per_worker' => 1,'auto_worker_min' => 0, 'auto_delay' => 15,
|
43
51
|
'log_snapshot_period' => 30, 'log_snapshot_lines' => 40, 'exec' => "bundle exec rake resque:work --trace"
|
@@ -86,6 +94,11 @@ module Resque
|
|
86
94
|
@host= params[:host]
|
87
95
|
my_show 'task'
|
88
96
|
end
|
97
|
+
|
98
|
+
app.get "/#{appn.downcase}/host/:host" do
|
99
|
+
@host= params[:host]
|
100
|
+
my_show 'host'
|
101
|
+
end
|
89
102
|
|
90
103
|
app.get "/#{appn.downcase}/config" do
|
91
104
|
content_type :json
|
@@ -122,6 +135,23 @@ module Resque
|
|
122
135
|
my_show 'stopit'
|
123
136
|
end
|
124
137
|
|
138
|
+
app.post "/#{appn.downcase}_mod_host/:host" do
|
139
|
+
host= params[:host]
|
140
|
+
ahost= params[:alias]
|
141
|
+
comment= params[:comment]
|
142
|
+
if ahost.blank? || ahost==host
|
143
|
+
redis.aliases_rem( host )
|
144
|
+
else
|
145
|
+
redis.aliases_add( host, ahost )
|
146
|
+
end
|
147
|
+
if comment.blank?
|
148
|
+
redis.comments_rem( host )
|
149
|
+
else
|
150
|
+
redis.comments_add( host, comment )
|
151
|
+
end
|
152
|
+
redirect "/resque/#{appn.downcase}"
|
153
|
+
end
|
154
|
+
|
125
155
|
app.post "/#{appn.downcase}_mod_task/:task" do
|
126
156
|
@task_id= params[:task]
|
127
157
|
@host= nil
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 1
|
9
|
+
version: 0.3.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Gilles Pirio
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2013-02-
|
17
|
+
date: 2013-02-28 00:00:00 -08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- lib/resque-telework/railtie.rb
|
66
66
|
- lib/resque-telework/redis.rb
|
67
67
|
- lib/resque-telework/server.rb
|
68
|
+
- lib/resque-telework/server/views/host.erb
|
68
69
|
- lib/resque-telework/server/views/misc.erb
|
69
70
|
- lib/resque-telework/server/views/revision.erb
|
70
71
|
- lib/resque-telework/server/views/stopit.erb
|