webs 0.1.15 → 0.1.16
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 +16 -22
- data/lib/webs.rb +1 -1
- data/webs.gemspec +1 -1
- metadata +3 -3
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'socket'
|
2
|
+
|
1
3
|
class Webs::AliveController < ActionController::Base
|
2
4
|
def index
|
3
5
|
# Returns a 500 before ever getting here if cannot connect to database
|
@@ -8,34 +10,26 @@ class Webs::AliveController < ActionController::Base
|
|
8
10
|
response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
|
9
11
|
|
10
12
|
# Only force down if calling from localhost
|
11
|
-
render( :text=>'OK' ) and return
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
server_down = Webs.cache.read(key)
|
20
|
-
if server_down.nil? && ['1', '-1'].include?( params['forceDown'])
|
13
|
+
render( :text=>'OK' ) and return unless Webs.cache
|
14
|
+
|
15
|
+
this_host = Socket.gethostname
|
16
|
+
key = "alive_#{this_host}"
|
17
|
+
|
18
|
+
server_down = Webs.cache.read(key)
|
19
|
+
if request.local?
|
20
|
+
if ['1', '-1'].include?( params['forceDown'] )
|
21
21
|
server_down = '1'
|
22
22
|
Webs.cache.write(key, server_down)
|
23
|
-
elsif
|
23
|
+
elsif params['forceDown'] == '0'
|
24
24
|
Webs.cache.delete(key)
|
25
25
|
server_down = nil
|
26
26
|
end
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
render :text=>'OK'
|
32
|
-
end
|
27
|
+
end
|
28
|
+
|
29
|
+
if server_down
|
30
|
+
render :text=>"Server is going down!", :status=>503
|
33
31
|
else
|
34
|
-
|
35
|
-
render :text=>"Server is going down!", :status=>503
|
36
|
-
else
|
37
|
-
render :text=>'OK'
|
38
|
-
end
|
32
|
+
render :text=>'OK'
|
39
33
|
end
|
40
34
|
end
|
41
35
|
end
|
data/lib/webs.rb
CHANGED
data/webs.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 59
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 16
|
10
|
+
version: 0.1.16
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Chuck Olczak
|