navy 1.0.2 → 1.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.
@@ -30,18 +30,69 @@ class Navy::Admiral < Navy::Rank
30
30
  attr_reader :options
31
31
 
32
32
  def initialize(options = {})
33
- self.reexec_pid = 0
34
-
35
33
  @options = options.dup
36
- @ready_pipe = @options.delete(:ready_pipe)
37
34
  @options[:use_defaults] = true
38
35
  self.orders = Navy::Admiral::Orders.new(self.class, @options)
39
36
 
40
- orders.give!(self, except: [ :stderr_path, :stdout_path ])
37
+ self.reexec_pid = 0
38
+ @ready_pipe = @options.delete(:ready_pipe)
39
+
40
+ @orders.give!(self)
41
+ # self.pid = "/tmp/navy.pid"
42
+ # @captains = {
43
+ # admin: {
44
+ # number: 3,
45
+ # job: ->(*args) {
46
+ # trap(:QUIT) { exit }
47
+ # trap(:TERM) { exit }
48
+ # n = 0
49
+ # loop do
50
+ # # Navy.logger.info "#{n} admin called #{args.inspect}"
51
+ # # Navy.logger.info "START_CTX: #{START_CTX.inspect}"
52
+ # # Navy.logger.info "Navy::Admiral::CAPTAINS: #{Navy::Admiral::CAPTAINS.inspect}"
53
+ # # Navy.logger.info "Navy::Admiral::OFFICERS: #{Navy::Captain::OFFICERS.inspect}"
54
+ # sleep 10
55
+ # n += 1
56
+ # end
57
+ # }
58
+ # },
59
+ # user: {
60
+ # number: 3,
61
+ # job: ->(*args) {
62
+ # trap(:QUIT) { exit }
63
+ # trap(:TERM) { exit }
64
+ # n = 0
65
+ # loop do
66
+ # # Navy.logger.info "#{n} user called #{args.inspect}"
67
+ # # Navy.logger.info "Navy::Admiral::CAPTAINS: #{Navy::Admiral::CAPTAINS.inspect}"
68
+ # # Navy.logger.info "Navy::Admiral::OFFICERS: #{Navy::Captain::OFFICERS.inspect}"
69
+ # sleep 10
70
+ # n += 1
71
+ # end
72
+ # }
73
+ # }
74
+ # }
75
+ # self.after_fork = ->(admiral, captain) do
76
+ # admiral.logger.info("captain=#{captain.label} spawned pid=#{$$}")
77
+ # end
78
+ # self.before_fork = ->(admiral, captain) do
79
+ # admiral.logger.info("captain=#{captain.label} spawning...")
80
+ # # old_pid = "#{admiral.pid}.oldbin"
81
+ # # if old_pid != admiral.pid
82
+ # # begin
83
+ # # sig = (captain.number + 1) >= captain.number ? :QUIT : :TTOU
84
+ # # Process.kill(sig, File.read(old_pid).to_i)
85
+ # # rescue Errno::ENOENT, Errno::ESRCH
86
+ # # end
87
+ # # end
88
+ # # sleep 1
89
+ # end
90
+ # self.before_exec = ->(admiral) do
91
+ # admiral.logger.info("forked child re-executing...")
92
+ # end
41
93
  end
42
94
 
43
95
  def start
44
- orders.give!(self, only: [ :stderr_path, :stdout_path ])
45
96
  init_self_pipe!
46
97
  QUEUE_SIGS.each do |sig|
47
98
  trap(sig) do
@@ -77,7 +128,7 @@ class Navy::Admiral < Navy::Rank
77
128
  # avoid murdering workers after our master process (or the
78
129
  # machine) comes out of suspend/hibernation
79
130
  if (last_check + @timeout) >= (last_check = Time.now)
80
- sleep_time = murder_lazy_captains
131
+ # sleep_time = murder_lazy_workers
81
132
  logger.debug("would normally murder lazy captains") if $DEBUG
82
133
  else
83
134
  sleep_time = @timeout/2.0 + 1
@@ -170,11 +221,6 @@ class Navy::Admiral < Navy::Rank
170
221
  end while true
171
222
  end
172
223
 
173
- # forcibly terminate all workers that haven't checked in in timeout seconds. The timeout is implemented using an unlinked File
174
- def murder_lazy_captains
175
- @timeout - 1
176
- end
177
-
178
224
  # reexecutes the START_CTX with a new binary
179
225
  def reexec
180
226
  if reexec_pid > 0
@@ -204,7 +250,7 @@ class Navy::Admiral < Navy::Rank
204
250
  logger.info "reexec admiral"
205
251
 
206
252
  self.reexec_pid = fork do
207
- # ENV['NAVY_FD'] = listener_fds.keys.join(',')
253
+ ENV['NAVY_FD'] = '1'
208
254
  Dir.chdir(START_CTX[:cwd])
209
255
  cmd = [ START_CTX[0] ].concat(START_CTX[:argv])
210
256
 
@@ -10,7 +10,6 @@ module Navy::Ship
10
10
  extend self
11
11
 
12
12
  def launch!(options)
13
- # cfg = Mule::Configurator
14
13
  $stdin.reopen("/dev/null")
15
14
 
16
15
  # We only start a new process group if we're not being reexecuted
@@ -43,8 +42,12 @@ module Navy::Ship
43
42
  end
44
43
  end
45
44
  # $stderr/$stderr can/will be redirected separately in the Unicorn config
46
- # cfg::DEFAULTS[:stderr_path] ||= "/dev/null"
47
- # cfg::DEFAULTS[:stdout_path] ||= "/dev/null"
45
+ # Navy::Orders.defaults[:stderr_path] ||= '/dev/null'
46
+ Navy::Admiral::Orders.defaults[:stderr_path] ||= '/dev/null'
47
+ # Navy::Captain::Orders.defaults[:stderr_path] ||= '/dev/null'
48
+ # Navy::Orders.defaults[:stdout_path] ||= '/dev/null'
49
+ Navy::Admiral::Orders.defaults[:stdout_path] ||= '/dev/null'
50
+ # Navy::Captain::Orders.defaults[:stdout_path] ||= '/dev/null'
48
51
  # cfg::SERVER[:daemonized] = true
49
52
  end
50
53
 
@@ -1,3 +1,3 @@
1
1
  module Navy
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
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: 1.0.2
4
+ version: 1.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pry
16
- requirement: &70201115937560 !ruby/object:Gem::Requirement
16
+ requirement: &70092620874740 !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: *70201115937560
24
+ version_requirements: *70092620874740
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &70201115937060 !ruby/object:Gem::Requirement
27
+ requirement: &70092620874200 !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: *70201115937060
35
+ version_requirements: *70092620874200
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70201115936440 !ruby/object:Gem::Requirement
38
+ requirement: &70092620922520 !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: *70201115936440
46
+ version_requirements: *70092620922520
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: kgio
49
- requirement: &70201115935780 !ruby/object:Gem::Requirement
49
+ requirement: &70092620921860 !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: *70201115935780
57
+ version_requirements: *70092620921860
58
58
  description: Ruby daemon inspired by Unicorn.
59
59
  email:
60
60
  - potatosaladx@gmail.com