scgi 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README +16 -4
- data/lib/scgi.rb +46 -35
- metadata +6 -6
data/LICENSE
CHANGED
data/README
CHANGED
@@ -31,7 +31,6 @@ Subversion access is available at svn://code.jeremyevans.net/ruby-scgi/.
|
|
31
31
|
* Simple to configure with your web server.
|
32
32
|
* Completely free code licensed under Rails's own license.
|
33
33
|
* No external dependencies other than Ruby
|
34
|
-
* The core implementation is easily extensible for other Ruby web frameworks.
|
35
34
|
|
36
35
|
== Comparison With FastCGI
|
37
36
|
|
@@ -75,13 +74,13 @@ ruby-scgi on a totally different machine with this.
|
|
75
74
|
|
76
75
|
ruby-scgi is now just a library and doesn't come with a tool to run Rails. The
|
77
76
|
previous command line tool (scgi_ctrl) has been greatly enhanced and is now
|
78
|
-
available as a standalone gem called style.
|
77
|
+
available as a standalone gem called ruby-style.
|
79
78
|
|
80
79
|
== Example configurations
|
81
80
|
|
82
81
|
Note that ruby-scgi is only tested on Lighttpd. Also, note that Lighttpd
|
83
82
|
1.4.16 has a bug which breaks redirects using server.error-handler-404, so
|
84
|
-
either use mod_magnet, use 1.4.
|
83
|
+
either use mod_magnet, use 1.4.18, or apply the patch in ticket 1270 on
|
85
84
|
Lighttpd's Trac.
|
86
85
|
|
87
86
|
Lighttpd:
|
@@ -141,9 +140,22 @@ Apache:
|
|
141
140
|
</Directory>
|
142
141
|
</VirtualHost>
|
143
142
|
|
143
|
+
== Changes from version 0.8.0
|
144
|
+
|
145
|
+
* You can pass a socket to SCGI::Processor.new via settings[:socket]
|
146
|
+
* You can have a socket created for you in new if you pass
|
147
|
+
settings[:host] and settings[:port]
|
148
|
+
* You can pass an existing logger to new via settings[:log]
|
149
|
+
* Passing a socket to listen is now optional, if you passed a socket or
|
150
|
+
had one created in new
|
151
|
+
* Improved RDoc for new
|
152
|
+
* Most SCGI::Processor methods are now private
|
153
|
+
* SCGI::Processor is easier to subclass because it will use preexisting
|
154
|
+
instance variables
|
155
|
+
|
144
156
|
== Changes from version 0.7.0
|
145
157
|
|
146
|
-
* Command line tool is now in a seperate gem called style
|
158
|
+
* Command line tool is now in a seperate gem called ruby-style
|
147
159
|
* You now must pass a socket to SCGI::Processor#listen
|
148
160
|
* SCGI::Processor's @log and @maxconns now have defaults
|
149
161
|
* SCGI::Processor's @host and @port are no longer used
|
data/lib/scgi.rb
CHANGED
@@ -81,22 +81,33 @@ module SCGI
|
|
81
81
|
# It might be useful for shared hosting people to have domain sockets, but
|
82
82
|
# they aren't supported in Apache, and in lighttpd they're unreliable.
|
83
83
|
# Also, domain sockets don't work so well on Windows.
|
84
|
+
#
|
85
|
+
# Available settings:
|
86
|
+
# :socket => Use this socket
|
87
|
+
# :host => Create a socket bound to this IP (if :port is also used)
|
88
|
+
# :port => Create a socket bound to this IP (if :host is also used)
|
89
|
+
# :log => Use this logger instead of creating one
|
90
|
+
# :logfile => Use this logfile instead of log/scgi.log
|
91
|
+
# :maxconns => Allow this many max connections, more than this are redirected
|
92
|
+
# to /busy.html (default: 2**30 - 1)
|
84
93
|
class Processor < Monitor
|
85
94
|
def initialize(settings = {})
|
86
|
-
@
|
87
|
-
@
|
88
|
-
@
|
89
|
-
@
|
90
|
-
@
|
91
|
-
@
|
95
|
+
@socket ||= settings[:socket] || (TCPServer.new(settings[:host], settings[:port]) if settings[:host] && settings[:port])
|
96
|
+
@total_conns ||= 0
|
97
|
+
@shutdown ||= false
|
98
|
+
@dead ||= false
|
99
|
+
@threads ||= Queue.new
|
100
|
+
@log ||= settings[:log] || LogFactory.instance.create(settings[:logfile] || 'log/scgi.log')
|
101
|
+
@maxconns ||= settings[:maxconns] || 2**30-1
|
92
102
|
super()
|
93
103
|
setup_signals
|
94
104
|
end
|
95
105
|
|
96
|
-
# Starts the SCGI::Processor having it listen on the given socket
|
106
|
+
# Starts the SCGI::Processor having it listen on the given socket, if one
|
107
|
+
# is provided, or the one established in new, if not. This
|
97
108
|
# function does not return until a shutdown.
|
98
|
-
def listen(socket)
|
99
|
-
@socket
|
109
|
+
def listen(socket = nil)
|
110
|
+
@socket ||= socket
|
100
111
|
|
101
112
|
# we also need a small collector thread that does nothing
|
102
113
|
# but pull threads off the thread queue and joins them
|
@@ -122,6 +133,32 @@ module SCGI
|
|
122
133
|
@log.info("Exited accept loop. Shutdown complete.")
|
123
134
|
end
|
124
135
|
|
136
|
+
# When called it will set the @shutdown flag indicating to the
|
137
|
+
# SCGI::Processor.listen function that all new connections should
|
138
|
+
# be set to /busy.html, and all current connections should be
|
139
|
+
# "valved" off. Once all the current connections are gone the
|
140
|
+
# SCGI::Processor.listen function will exit.
|
141
|
+
#
|
142
|
+
# Use the force=true parameter to force an immediate shutdown.
|
143
|
+
# This is done by closing the listening socket, so it's rather
|
144
|
+
# violent.
|
145
|
+
def shutdown(force = false)
|
146
|
+
synchronize do
|
147
|
+
@shutdown = true
|
148
|
+
|
149
|
+
if @threads.length == 0
|
150
|
+
@log.info("Immediate shutdown since nobody is connected.")
|
151
|
+
@socket.close
|
152
|
+
elsif force
|
153
|
+
@log.info("Forcing shutdown. You may see exceptions.")
|
154
|
+
@socket.close
|
155
|
+
else
|
156
|
+
@log.info("Shutdown requested. Beginning graceful shutdown with #{@threads.length} connected.")
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
private
|
125
162
|
def collect_thread(thread)
|
126
163
|
begin
|
127
164
|
thread.join
|
@@ -148,7 +185,6 @@ module SCGI
|
|
148
185
|
# and deals with the graceful shutdown. The important part
|
149
186
|
# of graceful shutdown is that new requests get redirected to
|
150
187
|
# the /busy.html file.
|
151
|
-
#
|
152
188
|
def handle_client(socket)
|
153
189
|
# ruby's GC seems to do weird things if we don't assign the thread to a local variable
|
154
190
|
@threads << Thread.new do
|
@@ -231,30 +267,5 @@ module SCGI
|
|
231
267
|
:shutdown => @shutdown, :dead => @dead, :total_conns => @total_conns
|
232
268
|
}.inspect
|
233
269
|
end
|
234
|
-
|
235
|
-
# When called it will set the @shutdown flag indicating to the
|
236
|
-
# SCGI::Processor.listen function that all new connections should
|
237
|
-
# be set to /busy.html, and all current connections should be
|
238
|
-
# "valved" off. Once all the current connections are gone the
|
239
|
-
# SCGI::Processor.listen function will exit.
|
240
|
-
#
|
241
|
-
# Use the force=true parameter to force an immediate shutdown.
|
242
|
-
# This is done by closing the listening socket, so it's rather
|
243
|
-
# violent.
|
244
|
-
def shutdown(force = false)
|
245
|
-
synchronize do
|
246
|
-
@shutdown = true
|
247
|
-
|
248
|
-
if @threads.length == 0
|
249
|
-
@log.info("Immediate shutdown since nobody is connected.")
|
250
|
-
@socket.close
|
251
|
-
elsif force
|
252
|
-
@log.info("Forcing shutdown. You may see exceptions.")
|
253
|
-
@socket.close
|
254
|
-
else
|
255
|
-
@log.info("Shutdown requested. Beginning graceful shutdown with #{@threads.length} connected.")
|
256
|
-
end
|
257
|
-
end
|
258
|
-
end
|
259
270
|
end
|
260
271
|
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.4
|
3
3
|
specification_version: 1
|
4
4
|
name: scgi
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date:
|
6
|
+
version: 0.9.0
|
7
|
+
date: 2008-01-23 00:00:00 -08:00
|
8
8
|
summary: Simple support for using SCGI in ruby apps, such as Rails
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
11
|
email: code@jeremyevans.net
|
12
12
|
homepage:
|
13
|
-
rubyforge_project:
|
13
|
+
rubyforge_project: scgi
|
14
14
|
description:
|
15
15
|
autorequire:
|
16
16
|
default_executable:
|
@@ -37,8 +37,8 @@ test_files: []
|
|
37
37
|
rdoc_options:
|
38
38
|
- --inline-source
|
39
39
|
- --line-numbers
|
40
|
-
extra_rdoc_files:
|
41
|
-
|
40
|
+
extra_rdoc_files:
|
41
|
+
- README
|
42
42
|
executables: []
|
43
43
|
|
44
44
|
extensions: []
|