webs 0.1.17 → 0.1.18
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/controller/alive_controller.rb +25 -6
- data/lib/webs.rb +1 -1
- data/webs.gemspec +1 -1
- metadata +2 -2
data/Rakefile
CHANGED
@@ -12,16 +12,13 @@ class Webs::AliveController < ActionController::Base
|
|
12
12
|
# Only force down if calling from localhost
|
13
13
|
render( :text=>'OK' ) and return unless Webs.cache
|
14
14
|
|
15
|
-
|
16
|
-
key = "alive_#{this_host}"
|
17
|
-
|
18
|
-
server_down = Webs.cache.read(key)
|
15
|
+
server_down = fetch_server_down
|
19
16
|
if request.local?
|
20
17
|
if ['1', '-1'].include?( params['forceDown'] )
|
21
18
|
server_down = '1'
|
22
|
-
|
19
|
+
set_server_down( server_down )
|
23
20
|
elsif params['forceDown'] == '0'
|
24
|
-
Webs.cache.delete(
|
21
|
+
Webs.cache.delete(cache_key)
|
25
22
|
server_down = nil
|
26
23
|
end
|
27
24
|
end
|
@@ -32,4 +29,26 @@ class Webs::AliveController < ActionController::Base
|
|
32
29
|
render :text=>'OK'
|
33
30
|
end
|
34
31
|
end
|
32
|
+
|
33
|
+
private
|
34
|
+
def cache_key
|
35
|
+
this_host = Socket.gethostname
|
36
|
+
"alive_#{this_host}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def fetch_server_down
|
40
|
+
if Webs.cache.respond_to?( 'read' )
|
41
|
+
Webs.cache.read( cache_key )
|
42
|
+
else
|
43
|
+
Webs.cache[ cache_key ]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def set_server_down server_down
|
48
|
+
if Webs.cache.respond_to?( 'write' )
|
49
|
+
Webs.cache.write(cache_key, server_down)
|
50
|
+
else
|
51
|
+
Webs.cache[ cache_key ] = server_down
|
52
|
+
end
|
53
|
+
end
|
35
54
|
end
|
data/lib/webs.rb
CHANGED
data/webs.gemspec
CHANGED