navy 0.0.2 → 0.0.3
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/bin/navy +15 -1
- data/lib/navy/admiral.rb +3 -3
- data/lib/navy/captain.rb +9 -3
- data/lib/navy/version.rb +1 -1
- metadata +9 -9
data/bin/navy
CHANGED
@@ -10,7 +10,13 @@ options = ship_options[:options]
|
|
10
10
|
|
11
11
|
op = OptionParser.new("", 24, ' ') do |opts|
|
12
12
|
cmd = File.basename($0)
|
13
|
-
opts.banner = "Usage: #{cmd} [#{cmd} options]"
|
13
|
+
opts.banner = "Usage: #{cmd} [ruby options] [#{cmd} options]"
|
14
|
+
|
15
|
+
opts.separator "Ruby options:"
|
16
|
+
|
17
|
+
opts.on("-d", "--debug", "set debugging flags (set $DEBUG to true)") do
|
18
|
+
$DEBUG = true
|
19
|
+
end
|
14
20
|
|
15
21
|
opts.separator "#{cmd} options:"
|
16
22
|
|
@@ -52,5 +58,13 @@ end
|
|
52
58
|
# })
|
53
59
|
# end
|
54
60
|
|
61
|
+
if $DEBUG
|
62
|
+
require 'pp'
|
63
|
+
pp({
|
64
|
+
navy_options: options,
|
65
|
+
daemonize: ship_options[:daemonize]
|
66
|
+
})
|
67
|
+
end
|
68
|
+
|
55
69
|
Navy::Ship.launch!(options) if ship_options[:daemonize]
|
56
70
|
Navy::Admiral.new(options).start.join
|
data/lib/navy/admiral.rb
CHANGED
@@ -82,7 +82,7 @@ class Navy::Admiral < Navy::Rank
|
|
82
82
|
init_self_pipe!
|
83
83
|
QUEUE_SIGS.each do |sig|
|
84
84
|
trap(sig) do
|
85
|
-
logger.
|
85
|
+
logger.debug "admiral received #{sig}" if $DEBUG
|
86
86
|
SIG_QUEUE << sig
|
87
87
|
awaken_admiral
|
88
88
|
end
|
@@ -114,7 +114,7 @@ class Navy::Admiral < Navy::Rank
|
|
114
114
|
# machine) comes out of suspend/hibernation
|
115
115
|
if (last_check + @timeout) >= (last_check = Time.now)
|
116
116
|
# sleep_time = murder_lazy_workers
|
117
|
-
logger.debug("would normally murder lazy captains")
|
117
|
+
logger.debug("would normally murder lazy captains") if $DEBUG
|
118
118
|
else
|
119
119
|
sleep_time = @timeout/2.0 + 1
|
120
120
|
logger.debug("waiting #{sleep_time}s after suspend/hibernation")
|
@@ -278,7 +278,7 @@ class Navy::Admiral < Navy::Rank
|
|
278
278
|
# delivers a signal to a captain and fails gracefully if the captain
|
279
279
|
# is no longer running.
|
280
280
|
def kill_captain(signal, cpid)
|
281
|
-
logger.
|
281
|
+
logger.debug "admiral sending #{signal} to #{cpid}" if $DEBUG
|
282
282
|
Process.kill(signal, cpid)
|
283
283
|
rescue Errno::ESRCH
|
284
284
|
captain = CAPTAINS.delete(cpid) rescue nil
|
data/lib/navy/captain.rb
CHANGED
@@ -37,7 +37,13 @@ class Navy::Captain < Navy::Rank
|
|
37
37
|
|
38
38
|
def start
|
39
39
|
init_self_pipe!
|
40
|
-
QUEUE_SIGS.each
|
40
|
+
QUEUE_SIGS.each do |sig|
|
41
|
+
trap(sig) do
|
42
|
+
logger.debug "captain[#{label}] received #{sig}" if $DEBUG
|
43
|
+
SIG_QUEUE << sig
|
44
|
+
awaken_captain
|
45
|
+
end
|
46
|
+
end
|
41
47
|
trap(:CHLD) { awaken_captain }
|
42
48
|
|
43
49
|
logger.info "captain[#{label}] starting"
|
@@ -62,7 +68,7 @@ class Navy::Captain < Navy::Rank
|
|
62
68
|
# machine) comes out of suspend/hibernation
|
63
69
|
if (last_check + @timeout) >= (last_check = Time.now)
|
64
70
|
# sleep_time = murder_lazy_workers
|
65
|
-
logger.debug("would normally murder lazy officers")
|
71
|
+
logger.debug("would normally murder lazy officers") if $DEBUG
|
66
72
|
else
|
67
73
|
sleep_time = @timeout/2.0 + 1
|
68
74
|
logger.debug("waiting #{sleep_time}s after suspend/hibernation")
|
@@ -183,7 +189,7 @@ class Navy::Captain < Navy::Rank
|
|
183
189
|
# delivers a signal to a officer and fails gracefully if the officer
|
184
190
|
# is no longer running.
|
185
191
|
def kill_officer(signal, opid)
|
186
|
-
logger.
|
192
|
+
logger.debug "captain[#{label}] sending #{signal} to #{opid}" if $DEBUG
|
187
193
|
Process.kill(signal, opid)
|
188
194
|
rescue Errno::ESRCH
|
189
195
|
officer = OFFICERS.delete(opid) rescue nil
|
data/lib/navy/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: navy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-03-04 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pry
|
16
|
-
requirement: &
|
16
|
+
requirement: &70181829400440 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70181829400440
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70181829399700 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70181829399700
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70181829398740 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 2.8.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70181829398740
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: kgio
|
49
|
-
requirement: &
|
49
|
+
requirement: &70181829398120 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '2.6'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70181829398120
|
58
58
|
description: Ruby daemon inspired by Unicorn.
|
59
59
|
email:
|
60
60
|
- potatosaladx@gmail.com
|