daemon_controller 0.2.2
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/LICENSE.txt +20 -0
- data/README.markdown +460 -0
- data/daemon_controller.gemspec +20 -0
- data/lib/daemon_controller.rb +626 -0
- data/lib/daemon_controller/lock_file.rb +126 -0
- data/spec/daemon_controller_spec.rb +288 -0
- data/spec/echo_server.rb +116 -0
- data/spec/test_helper.rb +73 -0
- metadata +62 -0
data/spec/test_helper.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
root = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
2
|
+
$LOAD_PATH.unshift(File.join(root, "lib"))
|
3
|
+
Dir.chdir(root)
|
4
|
+
|
5
|
+
module TestHelper
|
6
|
+
def new_controller(options = {})
|
7
|
+
start_command = './spec/echo_server.rb -l spec/echo_server.log -P spec/echo_server.pid'
|
8
|
+
if options[:wait1]
|
9
|
+
start_command << " --wait1 #{options[:wait1]}"
|
10
|
+
end
|
11
|
+
if options[:wait2]
|
12
|
+
start_command << " --wait2 #{options[:wait2]}"
|
13
|
+
end
|
14
|
+
if options[:stop_time]
|
15
|
+
start_command << " --stop-time #{options[:stop_time]}"
|
16
|
+
end
|
17
|
+
if options[:crash_before_bind]
|
18
|
+
start_command << " --crash-before-bind"
|
19
|
+
end
|
20
|
+
new_options = {
|
21
|
+
:identifier => 'My Test Daemon',
|
22
|
+
:start_command => start_command,
|
23
|
+
:ping_command => proc do
|
24
|
+
begin
|
25
|
+
TCPSocket.new('127.0.0.1', 3230)
|
26
|
+
true
|
27
|
+
rescue SystemCallError
|
28
|
+
false
|
29
|
+
end
|
30
|
+
end,
|
31
|
+
:pid_file => 'spec/echo_server.pid',
|
32
|
+
:log_file => 'spec/echo_server.log',
|
33
|
+
:start_timeout => 3,
|
34
|
+
:stop_timeout => 3
|
35
|
+
}.merge(options)
|
36
|
+
@controller = DaemonController.new(new_options)
|
37
|
+
end
|
38
|
+
|
39
|
+
def write_file(filename, contents)
|
40
|
+
File.open(filename, 'w') do |f|
|
41
|
+
f.write(contents)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def exec_is_slow?
|
46
|
+
return RUBY_PLATFORM == "java"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# A thread which doesn't execute its block until the
|
51
|
+
# 'go!' method has been called.
|
52
|
+
class WaitingThread < Thread
|
53
|
+
def initialize
|
54
|
+
@mutex = Mutex.new
|
55
|
+
@cond = ConditionVariable.new
|
56
|
+
@go = false
|
57
|
+
super do
|
58
|
+
@mutex.synchronize do
|
59
|
+
while !@go
|
60
|
+
@cond.wait(@mutex)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
yield
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def go!
|
68
|
+
@mutex.synchronize do
|
69
|
+
@go = true
|
70
|
+
@cond.broadcast
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: daemon_controller
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Hongli Lai
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-11-06 00:00:00 +01:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: A library for robust daemon management.
|
17
|
+
email: hongli@phusion.nl
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- README.markdown
|
26
|
+
- LICENSE.txt
|
27
|
+
- daemon_controller.gemspec
|
28
|
+
- lib/daemon_controller.rb
|
29
|
+
- lib/daemon_controller/lock_file.rb
|
30
|
+
- spec/test_helper.rb
|
31
|
+
- spec/daemon_controller_spec.rb
|
32
|
+
- spec/echo_server.rb
|
33
|
+
has_rdoc: true
|
34
|
+
homepage: http://github.com/FooBarWidget/daemon_controller/tree/master
|
35
|
+
licenses: []
|
36
|
+
|
37
|
+
post_install_message:
|
38
|
+
rdoc_options: []
|
39
|
+
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "0"
|
47
|
+
version:
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: "0"
|
53
|
+
version:
|
54
|
+
requirements: []
|
55
|
+
|
56
|
+
rubyforge_project:
|
57
|
+
rubygems_version: 1.3.5
|
58
|
+
signing_key:
|
59
|
+
specification_version: 3
|
60
|
+
summary: A library for implementing daemon management capabilities
|
61
|
+
test_files: []
|
62
|
+
|