forkr 0.1.6 → 0.1.7

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/forkr.gemspec +2 -2
  3. data/lib/forkr.rb +23 -20
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 296b325468b389dccd6a7cbe882b7b6640a3d3a6
4
- data.tar.gz: 9ee8107add29f14556346dbe34be3a5fde6111c0
3
+ metadata.gz: f0539b882a7e449399d84d53b5f84514db12af81
4
+ data.tar.gz: 41f718fe40fb072bd4c5e6f0e28953ac97f0d917
5
5
  SHA512:
6
- metadata.gz: 83a7313ee48f3d29f6db182608094c119f27bc2f2ea3efda79aaa0b55590722c0604b34d8247c79b5b375f00ba686caaaf6f651d85bd2b05e37626a366bc4cef
7
- data.tar.gz: c5c4baaefa584790d1517570a68e52d6cf9dbcd459c2088d9edf6872daef95d0290945265a005cb8df4e3a77609b70a91f6ba8ab7e5f79eda942f18f54bca79c
6
+ metadata.gz: 6c4f42032dee53cbfd4898dc0bdc9fae67146afdd68fe132c6d5338f4a9b21115057b8b981b70fde957a033266d66b471f2f06dd3313471c42c3de94c26802b6
7
+ data.tar.gz: bc1dd886ec97c7129f362bc56b2c9cd4fa4d98a5c6a45c7f93e1d74c2e7ebc8dfa10221380cd5bff34cf0f12c6fd7449be0bb16b307d63482b8048e08388e8fe
data/forkr.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'forkr'
3
- s.version = '0.1.6'
4
- s.date = '2014-12-03'
3
+ s.version = '0.1.7'
4
+ s.date = '2015-03-22'
5
5
  s.summary = "A pre-forking worker host - shamelessly inspired by unicorn."
6
6
  s.description = "Forkr is a preforking worker host, shamelessly inspired by unicorn. It exists to easily fork and scale ruby programs which aren't rack-based."
7
7
  s.authors = ["Trey Evans"]
data/lib/forkr.rb CHANGED
@@ -95,29 +95,31 @@ class Forkr
95
95
  end
96
96
 
97
97
  def master_loop
98
- ensure_right_worker_count
99
- loop do
100
- fds = IO.select([@inbound],nil,nil,2)
101
- unless fds.nil?
102
- data_read = fds.first.first.read(1)
103
- if data_read == "I"
104
- shutdown_using(:INT)
105
- elsif data_read == "T"
106
- shutdown_using(:TERM)
107
- elsif data_read == "Q"
108
- shutdown_using(:QUIT)
109
- elsif data_read == "+"
110
- increment_workers
111
- elsif data_read == "-"
112
- decrement_workers
98
+ catch(:bail_because_im_a_worker) do
99
+ ensure_right_worker_count
100
+ loop do
101
+ fds = IO.select([@inbound],nil,nil,2)
102
+ unless fds.nil?
103
+ data_read = fds.first.first.read(1)
104
+ if data_read == "I"
105
+ shutdown_using(:INT)
106
+ elsif data_read == "T"
107
+ shutdown_using(:TERM)
108
+ elsif data_read == "Q"
109
+ shutdown_using(:QUIT)
110
+ elsif data_read == "+"
111
+ increment_workers
112
+ elsif data_read == "-"
113
+ decrement_workers
114
+ end
113
115
  end
116
+ prune_workers
117
+ ensure_right_worker_count
114
118
  end
115
- prune_workers
116
- ensure_right_worker_count
119
+ reap_all_workers
120
+ @outbound.close
121
+ @inbound.close
117
122
  end
118
- reap_all_workers
119
- @outbound.close
120
- @inbound.close
121
123
  end
122
124
 
123
125
  def reap_all_workers
@@ -163,6 +165,7 @@ class Forkr
163
165
  @outbound.close
164
166
  $stderr.puts "Worker spawned as #{$$}!"
165
167
  @worker_client.run
168
+ throw(:bail_because_im_a_worker)
166
169
  end
167
170
 
168
171
  def child_dead?(pid)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forkr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trey Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-03 00:00:00.000000000 Z
11
+ date: 2015-03-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Forkr is a preforking worker host, shamelessly inspired by unicorn. It
14
14
  exists to easily fork and scale ruby programs which aren't rack-based.