robustserver 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/robustserver.rb +26 -12
- metadata +122 -39
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/lib/robustserver.rb
CHANGED
@@ -104,19 +104,21 @@ end
|
|
104
104
|
# Subclasses should implements *#run*, which will be your main-worker.
|
105
105
|
# For initializing, you can override **#initialize**, but doen't forget to call **super**.
|
106
106
|
class RobustServer
|
107
|
-
|
107
|
+
class UnimplementedRun <Exception
|
108
|
+
end
|
109
|
+
attr_reader :signals, :output
|
108
110
|
|
109
111
|
def self.main *argv
|
110
112
|
self.new( *argv).main
|
111
113
|
end
|
112
114
|
|
113
|
-
def initialize *
|
115
|
+
def initialize *_
|
114
116
|
sh = method :signal_handler
|
115
117
|
@sigs = {
|
116
118
|
Signal[:INT] => sh, Signal[:HUP] => nil, Signal[:TERM] => sh,
|
117
119
|
Signal[:KILL] => sh, Signal[:USR1] => nil, Signal[:USR2] => nil
|
118
120
|
}
|
119
|
-
@signals = []
|
121
|
+
@signals, @output = [], $stderr
|
120
122
|
end
|
121
123
|
|
122
124
|
def trapping
|
@@ -124,28 +126,40 @@ class RobustServer
|
|
124
126
|
end
|
125
127
|
|
126
128
|
def signal_handler s
|
127
|
-
|
128
|
-
s = s
|
129
|
+
output.puts [:signal, s, Signal[s]].inspect
|
129
130
|
@signals.push s unless @signals.include? s
|
130
131
|
end
|
131
132
|
|
132
133
|
def main max = nil, range = nil
|
133
134
|
retries = Retries.new max, range
|
134
135
|
trapping
|
135
|
-
|
136
|
+
output.puts "Running...."
|
136
137
|
begin
|
137
138
|
self.run
|
138
|
-
rescue
|
139
|
-
|
139
|
+
rescue UnimplementedRun
|
140
|
+
output.puts $!.message
|
141
|
+
exit 1
|
142
|
+
rescue SystemExit
|
143
|
+
output.puts "Server interrupted by signal: #$!"
|
144
|
+
raise
|
145
|
+
rescue Interrupt, SignalException
|
146
|
+
output.puts "Server interrupted by signal: #$!"
|
147
|
+
exit 0
|
140
148
|
rescue Object
|
141
|
-
|
149
|
+
output.puts [:rescue, $!, $!.class, $!.backtrace].inspect
|
142
150
|
retry if retries.retry?
|
143
|
-
|
151
|
+
output.print "Too many errors in too short time. Give up: "
|
152
|
+
exit 2
|
144
153
|
end
|
145
|
-
|
154
|
+
ensure
|
155
|
+
output.puts "Disregarded signals: #{@signals.map(&Signal.method(:[])).join( ', ')}" unless @signals.empty?
|
146
156
|
trapping
|
147
157
|
self.at_exit
|
148
|
-
|
158
|
+
output.puts "Shutdown."
|
159
|
+
end
|
160
|
+
|
161
|
+
def run
|
162
|
+
raise UnimplementedRun, "Unimplemented #{self.class.name}#run."
|
149
163
|
end
|
150
164
|
|
151
165
|
def at_exit
|
metadata
CHANGED
@@ -1,67 +1,150 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: robustserver
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
version: 0.0.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Denis Knauf
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
12
|
+
date: 2013-04-15 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: shoulda
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: yard
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rdoc
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: bundler
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: jeweler
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: simplecov
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
21
110
|
description: Protects your Server against SIGS and rescues all exceptions.
|
22
111
|
email: Denis.Knauf@gmail.com
|
23
112
|
executables: []
|
24
|
-
|
25
113
|
extensions: []
|
26
|
-
|
27
|
-
extra_rdoc_files:
|
114
|
+
extra_rdoc_files:
|
28
115
|
- LICENSE
|
29
116
|
- README.md
|
30
|
-
files:
|
117
|
+
files:
|
31
118
|
- AUTHORS
|
32
119
|
- README.md
|
33
120
|
- VERSION
|
34
121
|
- lib/robustserver.rb
|
35
122
|
- LICENSE
|
36
|
-
has_rdoc: true
|
37
123
|
homepage: http://github.com/DenisKnauf/robustserver
|
38
124
|
licenses: []
|
39
|
-
|
40
125
|
post_install_message:
|
41
|
-
rdoc_options:
|
42
|
-
|
43
|
-
require_paths:
|
126
|
+
rdoc_options: []
|
127
|
+
require_paths:
|
44
128
|
- lib
|
45
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
-
requirements:
|
54
|
-
- - ">="
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
segments:
|
129
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
+
none: false
|
131
|
+
requirements:
|
132
|
+
- - ! '>='
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
segments:
|
57
136
|
- 0
|
58
|
-
|
137
|
+
hash: -383789649
|
138
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
|
+
none: false
|
140
|
+
requirements:
|
141
|
+
- - ! '>='
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
59
144
|
requirements: []
|
60
|
-
|
61
145
|
rubyforge_project:
|
62
|
-
rubygems_version: 1.
|
146
|
+
rubygems_version: 1.8.23
|
63
147
|
signing_key:
|
64
148
|
specification_version: 3
|
65
149
|
summary: Robust Server
|
66
150
|
test_files: []
|
67
|
-
|