servolux 0.10.0 → 0.11.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.
@@ -1,19 +1,15 @@
1
-
2
1
  require File.expand_path('../spec_helper', __FILE__)
3
2
 
4
3
  describe Servolux do
5
-
6
4
  before :all do
7
5
  @root_dir = File.expand_path(File.join(File.dirname(__FILE__), '..'))
8
6
  end
9
7
 
10
8
  it "finds things releative to 'lib'" do
11
- Servolux.libpath(%w[servolux threaded]).should == File.join(@root_dir, %w[lib servolux threaded])
9
+ expect(Servolux.libpath(%w[servolux threaded])).to eq(File.join(@root_dir, %w[lib servolux threaded]))
12
10
  end
13
11
 
14
12
  it "finds things releative to 'root'" do
15
- Servolux.path('Rakefile').should == File.join(@root_dir, 'Rakefile')
13
+ expect(Servolux.path('Rakefile')).to eq(File.join(@root_dir, 'Rakefile'))
16
14
  end
17
-
18
15
  end
19
-
@@ -1,4 +1,3 @@
1
-
2
1
  unless defined? SERVOLUX_SPEC_HELPER
3
2
  SERVOLUX_SPEC_HELPER = true
4
3
 
@@ -15,6 +14,4 @@ RSpec.configure do |config|
15
14
  include RSpec::LoggingHelper
16
15
  config.capture_log_messages
17
16
  end
18
-
19
17
  end # unless defined?
20
-
@@ -1,8 +1,6 @@
1
-
2
1
  require File.expand_path('../spec_helper', __FILE__)
3
2
 
4
3
  describe Servolux::Threaded do
5
-
6
4
  base = Class.new do
7
5
  include Servolux::Threaded
8
6
  def initialize
@@ -33,14 +31,14 @@ describe Servolux::Threaded do
33
31
 
34
32
  obj = klass.new
35
33
  obj.interval = 0
36
- obj.running?.should be_nil
34
+ expect(obj.running?).to be_nil
37
35
 
38
36
  obj.start
39
- obj.running?.should be_true
37
+ expect(obj).to be_running
40
38
  obj.pass
41
39
 
42
40
  obj.stop.join(2)
43
- obj.running?.should be_false
41
+ expect(obj).to_not be_running
44
42
  end
45
43
 
46
44
  it "stops even when sleeping in the run method" do
@@ -53,14 +51,14 @@ describe Servolux::Threaded do
53
51
 
54
52
  obj = klass.new
55
53
  obj.interval = 0
56
- obj.stopped.should be_nil
54
+ expect(obj.stopped).to be_nil
57
55
 
58
56
  obj.start
59
- obj.stopped.should be_false
57
+ expect(obj.stopped).to be false
60
58
  obj.pass
61
59
 
62
60
  obj.stop.join(2)
63
- obj.stopped.should be_true
61
+ expect(obj.stopped).to be true
64
62
  end
65
63
 
66
64
  it "calls all the before and after hooks" do
@@ -78,11 +76,11 @@ describe Servolux::Threaded do
78
76
  obj.ary = []
79
77
 
80
78
  obj.start
81
- obj.ary.should be == [1,2]
79
+ expect(obj.ary).to eq([1,2])
82
80
  obj.pass
83
81
 
84
82
  obj.stop.join(2)
85
- obj.ary.should be == [1,2,3,4]
83
+ expect(obj.ary).to eq([1,2,3,4])
86
84
  end
87
85
 
88
86
  it "dies when an exception is thrown" do
@@ -95,11 +93,11 @@ describe Servolux::Threaded do
95
93
  obj.start
96
94
  obj.pass nil
97
95
 
98
- obj.running?.should be_false
96
+ expect(obj).to_not be_running
99
97
  @log_output.readline
100
- @log_output.readline.chomp.should be == "FATAL Object : <RuntimeError> ni"
98
+ expect(@log_output.readline.chomp).to eq("FATAL Object : <RuntimeError> ni")
101
99
 
102
- lambda { obj.join }.should raise_error(RuntimeError, 'ni')
100
+ expect { obj.join }.to raise_error(RuntimeError, 'ni')
103
101
  end
104
102
 
105
103
  it "lives if told to continue on error" do
@@ -122,12 +120,12 @@ describe Servolux::Threaded do
122
120
  obj.start
123
121
  obj.wait_signal
124
122
 
125
- obj.running?.should be_true
123
+ expect(obj).to be_running
126
124
  @log_output.readline
127
- @log_output.readline.chomp.should be == "ERROR Object : <RuntimeError> ni"
125
+ expect(@log_output.readline.chomp).to eq("ERROR Object : <RuntimeError> ni")
128
126
 
129
127
  obj.stop.join(2)
130
- obj.running?.should be_false
128
+ expect(obj).to_not be_running
131
129
  end
132
130
 
133
131
  it "complains loudly if you don't have a run method" do
@@ -136,9 +134,9 @@ describe Servolux::Threaded do
136
134
  obj.pass nil
137
135
 
138
136
  @log_output.readline
139
- @log_output.readline.chomp.should be == "FATAL Object : <NotImplementedError> The run method must be defined by the threaded object."
137
+ expect(@log_output.readline.chomp).to eq("FATAL Object : <NotImplementedError> The run method must be defined by the threaded object.")
140
138
 
141
- lambda { obj.join }.should raise_error(NotImplementedError, 'The run method must be defined by the threaded object.')
139
+ expect { obj.join }.to raise_error(NotImplementedError, 'The run method must be defined by the threaded object.')
142
140
  end
143
141
 
144
142
  # --------------------------------------------------------------------------
@@ -151,11 +149,11 @@ describe Servolux::Threaded do
151
149
 
152
150
  obj = klass.new
153
151
  obj.maximum_iterations = 5
154
- obj.iterations.should be == 0
152
+ expect(obj.iterations).to eq(0)
155
153
 
156
154
  obj.start
157
155
  obj.wait
158
- obj.iterations.should be == 5
156
+ expect(obj.iterations).to eq(5)
159
157
  end
160
158
 
161
159
  it "runs the 'after_stopping' method" do
@@ -171,7 +169,7 @@ describe Servolux::Threaded do
171
169
 
172
170
  obj.start
173
171
  obj.wait
174
- obj.ary.should be == [4]
172
+ expect(obj.ary).to eq([4])
175
173
  end
176
174
 
177
175
  it "should not increment iterations if maximum iterations has not been set" do
@@ -180,19 +178,55 @@ describe Servolux::Threaded do
180
178
  end
181
179
 
182
180
  obj = klass.new
183
- obj.iterations.should be == 0
181
+ expect(obj.iterations).to eq(0)
184
182
 
185
183
  obj.start
186
184
  sleep 0.1
187
185
  obj.stop.join(2)
188
- obj.iterations.should be == 0
186
+ expect(obj.iterations).to eq(0)
189
187
  end
190
188
 
191
189
  it "complains loudly if you attempt to set a maximum number of iterations < 1" do
192
190
  obj = base.new
193
- lambda { obj.maximum_iterations = -1 }.should raise_error( ArgumentError, "maximum iterations must be >= 1" )
191
+ expect { obj.maximum_iterations = -1 }.to raise_error( ArgumentError, "maximum iterations must be >= 1" )
194
192
  end
193
+ end
194
+
195
+ # --------------------------------------------------------------------------
196
+ context 'when running with a strict interval' do
197
+
198
+ it "logs a warning if the strict interval is exceeded" do
199
+ klass = Class.new( base ) do
200
+ def run() sleep 0.5; end
201
+ end
202
+
203
+ obj = klass.new
204
+ obj.interval = 0.250
205
+ obj.use_strict_interval = true
206
+ obj.maximum_iterations = 2
207
+
208
+ obj.start
209
+ obj.wait
195
210
 
211
+ @log_output.readline
212
+ expect(@log_output.readline.chomp).to match(%r/ WARN Servolux::Threaded::ThreadContainer : Run time \[\d+\.\d+ s\] exceeded strict interval \[0\.25 s\]/)
213
+ end
214
+
215
+ it "ignores the strict flag if the interval is zero" do
216
+ klass = Class.new( base ) do
217
+ def run() sleep 0.250; end
218
+ end
219
+
220
+ obj = klass.new
221
+ obj.interval = 0
222
+ obj.use_strict_interval = true
223
+ obj.maximum_iterations = 2
224
+
225
+ obj.start
226
+ obj.wait
227
+
228
+ @log_output.readline
229
+ expect(@log_output.readline).to be_nil
230
+ end
196
231
  end
197
232
  end
198
-
metadata CHANGED
@@ -1,79 +1,86 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servolux
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
5
- prerelease:
4
+ version: 0.11.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Tim Pease
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-02-18 00:00:00.000000000Z
11
+ date: 2015-05-30 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bones-rspec
16
- requirement: &2160654620 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: 2.0.1
19
+ version: '2.0'
22
20
  type: :development
23
21
  prerelease: false
24
- version_requirements: *2160654620
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: bones-git
27
- requirement: &2160654100 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ! '>='
31
+ - - "~>"
31
32
  - !ruby/object:Gem::Version
32
- version: 1.2.5
33
+ version: '1.3'
33
34
  type: :development
34
35
  prerelease: false
35
- version_requirements: *2160654100
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: logging
38
- requirement: &2160653660 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
- - - ! '>='
45
+ - - "~>"
42
46
  - !ruby/object:Gem::Version
43
- version: 1.6.2
47
+ version: '2.0'
44
48
  type: :development
45
49
  prerelease: false
46
- version_requirements: *2160653660
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
47
55
  - !ruby/object:Gem::Dependency
48
56
  name: bones
49
- requirement: &2160653220 !ruby/object:Gem::Requirement
50
- none: false
57
+ requirement: !ruby/object:Gem::Requirement
51
58
  requirements:
52
- - - ! '>='
59
+ - - ">="
53
60
  - !ruby/object:Gem::Version
54
- version: 3.7.2
61
+ version: 3.8.3
55
62
  type: :development
56
63
  prerelease: false
57
- version_requirements: *2160653220
58
- description: ! 'Serv-O-Lux is a collection of Ruby classes that are useful for daemon
59
- and
60
-
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 3.8.3
69
+ description: |-
70
+ Serv-O-Lux is a collection of Ruby classes that are useful for daemon and
61
71
  process management, and for writing your own Ruby services. The code is well
62
-
63
72
  documented and tested. It works with Ruby and JRuby supporting both 1.8 and 1.9
64
-
65
- interpreters.'
73
+ interpreters.
66
74
  email: tim.pease@gmail.com
67
75
  executables: []
68
76
  extensions: []
69
77
  extra_rdoc_files:
70
78
  - History.txt
71
- - README.rdoc
72
79
  files:
73
- - .gitignore
74
- - .travis.yml
80
+ - ".gitignore"
81
+ - ".travis.yml"
75
82
  - History.txt
76
- - README.rdoc
83
+ - README.md
77
84
  - Rakefile
78
85
  - examples/beanstalk.rb
79
86
  - examples/echo.rb
@@ -86,6 +93,8 @@ files:
86
93
  - lib/servolux/prefork.rb
87
94
  - lib/servolux/server.rb
88
95
  - lib/servolux/threaded.rb
96
+ - lib/servolux/version.rb
97
+ - script/bootstrap
89
98
  - spec/child_spec.rb
90
99
  - spec/daemon_spec.rb
91
100
  - spec/piper_spec.rb
@@ -94,31 +103,29 @@ files:
94
103
  - spec/servolux_spec.rb
95
104
  - spec/spec_helper.rb
96
105
  - spec/threaded_spec.rb
97
- - version.txt
98
- homepage: http://gemcutter.org/gems/servolux
106
+ homepage: http://rubygems.org/gems/servolux
99
107
  licenses: []
108
+ metadata: {}
100
109
  post_install_message:
101
110
  rdoc_options:
102
- - --main
103
- - README.rdoc
111
+ - "--main"
112
+ - README.md
104
113
  require_paths:
105
114
  - lib
106
115
  required_ruby_version: !ruby/object:Gem::Requirement
107
- none: false
108
116
  requirements:
109
- - - ! '>='
117
+ - - ">="
110
118
  - !ruby/object:Gem::Version
111
119
  version: '0'
112
120
  required_rubygems_version: !ruby/object:Gem::Requirement
113
- none: false
114
121
  requirements:
115
- - - ! '>='
122
+ - - ">="
116
123
  - !ruby/object:Gem::Version
117
124
  version: '0'
118
125
  requirements: []
119
126
  rubyforge_project: servolux
120
- rubygems_version: 1.8.11
127
+ rubygems_version: 2.2.3
121
128
  signing_key:
122
- specification_version: 3
123
- summary: ! '* {Homepage}[http://rubygems.'
129
+ specification_version: 4
130
+ summary: A collection of tools for working with processes
124
131
  test_files: []
@@ -1,68 +0,0 @@
1
- = Serv-O-Lux
2
- by Tim Pease {<img src="https://secure.travis-ci.org/TwP/servolux.png">}[http://travis-ci.org/TwP/servolux]
3
-
4
- * {Homepage}[http://rubygems.org/gems/servolux]
5
- * {Github Project}[http://github.com/TwP/servolux]
6
-
7
- === DESCRIPTION
8
-
9
- Serv-O-Lux is a collection of Ruby classes that are useful for daemon and
10
- process management, and for writing your own Ruby services. The code is well
11
- documented and tested. It works with Ruby and JRuby supporting both 1.8 and 1.9
12
- interpreters.
13
-
14
- === FEATURES
15
-
16
- Servolux::Threaded -- when included into your own class, it gives you an
17
- activity thread that will run some code at a regular interval. Provides methods
18
- to start and stop the thread, report on the running state, and join the thread
19
- to wait for it to complete.
20
-
21
- Servolux::Server -- a template server class that handles the mundane work of
22
- creating / deleting a PID file, reporting running state, logging errors,
23
- starting the service, and gracefully shutting down the service.
24
-
25
- Servolux::Piper -- an extension of the standard Ruby fork method that opens a
26
- pipe for communication between parent and child processes. Ruby objects are
27
- passed between parent and child allowing, for example, exceptions in the child
28
- process to be passed to the parent and raised there.
29
-
30
- Servolux::Daemon -- a robust class for starting and stopping daemon processes.
31
-
32
- Servolux::Child -- adds some much needed functionality to child processes
33
- created via Ruby's IO#popen method. Specifically, a timeout thread is used to
34
- signal the child process to die if it does not exit in a given amount of time.
35
-
36
- Servolux::Prefork -- provides a pre-forking worker pool for executing tasks in
37
- parallel using multiple processes.
38
-
39
- All the documentation is available online at http://rdoc.info/projects/TwP/servolux
40
-
41
- === INSTALL
42
-
43
- gem install servolux
44
-
45
- === LICENSE
46
-
47
- (The MIT License)
48
-
49
- Copyright (c) 2009
50
-
51
- Permission is hereby granted, free of charge, to any person obtaining
52
- a copy of this software and associated documentation files (the
53
- 'Software'), to deal in the Software without restriction, including
54
- without limitation the rights to use, copy, modify, merge, publish,
55
- distribute, sublicense, and/or sell copies of the Software, and to
56
- permit persons to whom the Software is furnished to do so, subject to
57
- the following conditions:
58
-
59
- The above copyright notice and this permission notice shall be
60
- included in all copies or substantial portions of the Software.
61
-
62
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
63
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
64
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
65
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
66
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
67
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
68
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.