spider-gazelle 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5bfe3d42157275bcfbeffa8ca47db111ef0e54a6
4
- data.tar.gz: 62004f3562195671e37568b9b898e5bd42a8f6d8
3
+ metadata.gz: d15ffeefedb38fb84b5c83512debaa30ca98f8d0
4
+ data.tar.gz: 34f054e675f5ad91168086e45bd0d518c0907027
5
5
  SHA512:
6
- metadata.gz: 92ca1d1bfae49106c7e9e77c120cfe86a1ea242e886820c3d83fe96245a069495006e4f954badce2d5c9beca3c29b82745142c3c90e3fc54c9285bbb5770751d
7
- data.tar.gz: e9f1d5d5547df22e46ed2755a6bba86b19bd07a8a4ee837ac6649dbc2c0114f4a9384c22b8941d23516e63e0a3fc98d6951583cb9fcb90c27464e16f79229e19
6
+ metadata.gz: 4f50ee47e045cfe496e34334f61a594247cfaead769b0cf86de1ce016a66c4df155043c7a1443539c745ee0bc7f975e343ac52d55cf535b2156fd12a136ce813
7
+ data.tar.gz: aceba5158162fa338f8b64b9ef7d82487e66a61ebe8dd422141b057584dafff49ceb44948cfd73bbddcd2baabc04da54f65a2ff85b30be6efb8b0c6c074021eb
data/bin/sg CHANGED
@@ -38,10 +38,6 @@ parser = OptionParser.new do |opts|
38
38
  ENV['SG_LOG'] = arg
39
39
  end
40
40
 
41
- opts.on "-P", "--pid FILE", "Location of the servers pid file (default: tmp/pids/sg-PORT.pid)" do |arg|
42
- ENV['SG_PID'] = arg
43
- end
44
-
45
41
  opts.on "-m", "--mode MODE", "Either thread, process or no_ipc (default: thread)" do |arg|
46
42
  ENV['SG_MODE'] = arg
47
43
  end
@@ -7,8 +7,6 @@ require "spider-gazelle/request" # Holds request information and handles
7
7
  require "spider-gazelle/connection" # Holds connection information and handles request pipelining
8
8
  require "spider-gazelle/gazelle" # Processes data received from connections
9
9
 
10
- require "spider-gazelle/management/process" # Processes data received from connections
11
-
12
10
  require "spider-gazelle/app_store" # Holds references to the loaded rack applications
13
11
  require "spider-gazelle/binding" # Holds a reference to a bound port and associated rack application
14
12
  require "spider-gazelle/spider" # Accepts connections and offloads them to gazelles
@@ -258,6 +258,13 @@ module SpiderGazelle
258
258
 
259
259
  body.close if body.respond_to?(:close)
260
260
  end
261
+
262
+ def add_header(header, key, value)
263
+ header << key
264
+ header << COLON_SPACE
265
+ header << value
266
+ header << LINE_END
267
+ end
261
268
 
262
269
  def write_headers(status, headers)
263
270
  headers[CONNECTION] = CLOSE if @request.keep_alive == false
@@ -265,13 +272,7 @@ module SpiderGazelle
265
272
  header = "HTTP/1.1 #{status} #{fetch_code(status)}\r\n"
266
273
  headers.each do |key, value|
267
274
  next if key.start_with? RACK
268
-
269
- value.split(NEWLINE).each do |unique_value|
270
- header << key
271
- header << COLON_SPACE
272
- header << unique_value
273
- header << LINE_END
274
- end
275
+ value.to_s.split(NEWLINE).each {|val| add_header(header, key, val)}
275
276
  end
276
277
  header << LINE_END
277
278
  @socket.write header
@@ -27,7 +27,7 @@ module SpiderGazelle
27
27
  # REMOTE_USER, or REMOTE_HOST parameters since those are either a security problem or
28
28
  # too taxing on performance.
29
29
  module Const
30
- SPIDER_GAZELLE_VERSION = VERSION = "1.0.3".freeze
30
+ SPIDER_GAZELLE_VERSION = VERSION = "1.0.4".freeze
31
31
  # CODE_NAME = "Earl of Sandwich Partition"
32
32
  SERVER = "SpiderGazelle".freeze
33
33
 
@@ -75,15 +75,6 @@ module SpiderGazelle
75
75
  FileUtils.mkdir_p(dirname) unless File.directory?(dirname)
76
76
  @logger = ::Logger.new(log_path.to_s, 10, 4194304)
77
77
 
78
- unless ::FFI::Platform.windows?
79
- # Create the PID file
80
- pid_path = ENV['SG_PID'] || File.expand_path('tmp/pids/sg.pid', Dir.pwd)
81
- dirname = File.dirname(pid_path)
82
- FileUtils.mkdir_p(dirname) unless File.directory?(dirname)
83
- @pid = Management::Pid.new(pid_path)
84
- end
85
-
86
-
87
78
  # Keep track of the loading process
88
79
  @waiting_gazelle = 0
89
80
  @gazelle_count = 0
@@ -297,8 +288,6 @@ module SpiderGazelle
297
288
  # Signal gazelle death here
298
289
  @web.signal :INT, @squash
299
290
 
300
- @wait = @web.async {}
301
-
302
291
  # Update state only once the event loop is ready
303
292
  @gazelles_loaded.promise
304
293
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spider-gazelle
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen von Takach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-23 00:00:00.000000000 Z
11
+ date: 2015-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -160,7 +160,6 @@ files:
160
160
  - lib/spider-gazelle/connection.rb
161
161
  - lib/spider-gazelle/const.rb
162
162
  - lib/spider-gazelle/gazelle.rb
163
- - lib/spider-gazelle/management/process.rb
164
163
  - lib/spider-gazelle/request.rb
165
164
  - lib/spider-gazelle/spider.rb
166
165
  - lib/spider-gazelle/upgrades/websocket.rb
@@ -186,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
185
  version: '0'
187
186
  requirements: []
188
187
  rubyforge_project:
189
- rubygems_version: 2.2.2
188
+ rubygems_version: 2.4.5
190
189
  signing_key:
191
190
  specification_version: 4
192
191
  summary: A fast, parallel and concurrent web server for ruby
@@ -1,90 +0,0 @@
1
-
2
- if ::FFI::Platform.windows?
3
- begin
4
- require 'win32/process'
5
- rescue LoadError
6
- puts "Warning: The win32-process gem is required for PID file use on Windows. Install the gem (in your Gemfile if using bundler) to avoid errors."
7
- end
8
- end
9
-
10
- module SpiderGazelle
11
- class PidFileExists < RuntimeError; end
12
-
13
- module Management
14
- class Pid
15
- def initialize(path)
16
- @pid_file = path
17
-
18
- remove_stale_pid_file
19
- write_pid_file
20
-
21
- # At application exit remove the file
22
- # unless of course we do not own the file
23
- cur = ::Process.pid
24
- at_exit do
25
- if cur == current
26
- remove_pid_file
27
- end
28
- end
29
- end
30
-
31
- def current
32
- File.exist?(@pid_file) ? open(@pid_file).read.to_i : nil
33
- end
34
-
35
- def running?(pid)
36
- if ::FFI::Platform.windows?
37
- begin
38
- # Returns exit code or nil if still running
39
- if ::Process.respond_to? :get_exitcode
40
- return ::Process.get_exitcode(pid).nil?
41
- else
42
- # win32/process not loaded
43
- return false
44
- end
45
- rescue
46
- # PID probably doesn't exist
47
- false
48
- end
49
- else
50
- begin
51
- ::Process.getpgid(pid) != -1
52
- rescue ::Errno::EPERM
53
- # Operation not permitted
54
- true
55
- rescue ::Errno::ESRCH
56
- # No such process
57
- false
58
- end
59
- end
60
- end
61
-
62
- protected
63
-
64
-
65
- def remove_stale_pid_file
66
- if File.exist?(@pid_file)
67
- pid = current
68
-
69
- if pid && running?(pid)
70
- raise PidFileExists, "#{@pid_file} already exists, seems like it's already running (process ID: #{pid}). " +
71
- "Stop the process or delete #{@pid_file}."
72
- else
73
- remove_pid_file
74
- end
75
- end
76
- end
77
-
78
- def write_pid_file
79
- File.open(@pid_file, 'w') do |f|
80
- f.write ::Process.pid
81
- end
82
- File.chmod(0644, @pid_file)
83
- end
84
-
85
- def remove_pid_file
86
- File.delete(@pid_file) if @pid_file && File.exists?(@pid_file)
87
- end
88
- end
89
- end
90
- end