mongrel2 0.21.0 → 0.22.1

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/ChangeLog CHANGED
@@ -1,8 +1,62 @@
1
+ 2012-05-07 Michael Granger <ged@FaerieMUD.org>
2
+
3
+ * .hgtags:
4
+ Added tag v0.22.0 for changeset 82e0a3ed6dc5
5
+ [666e8d88a6d7] [tip]
6
+
7
+ * .hgsigs:
8
+ Added signature for changeset e25ffaab1897
9
+ [82e0a3ed6dc5] [v0.22.0]
10
+
11
+ * History.rdoc, Manifest.txt, lib/mongrel2.rb:
12
+ Bump the minor version, update history and manifest.
13
+ [e25ffaab1897]
14
+
15
+ * .rvm.gems, Rakefile, bin/m2sh.rb, examples/helloworld-handler.rb,
16
+ examples/request-dumper.rb, examples/ws-echo.rb,
17
+ experiments/endtoend.rb, experiments/xmlhandler.rb, lib/mongrel2.rb,
18
+ lib/mongrel2/config.rb, lib/mongrel2/config/dsl.rb,
19
+ lib/mongrel2/config/host.rb, lib/mongrel2/config/server.rb,
20
+ lib/mongrel2/connection.rb, lib/mongrel2/control.rb,
21
+ lib/mongrel2/handler.rb, lib/mongrel2/httprequest.rb,
22
+ lib/mongrel2/httpresponse.rb, lib/mongrel2/jsonrequest.rb,
23
+ lib/mongrel2/logging.rb, lib/mongrel2/mixins.rb,
24
+ lib/mongrel2/request.rb, lib/mongrel2/response.rb,
25
+ lib/mongrel2/table.rb, lib/mongrel2/testing.rb,
26
+ lib/mongrel2/websocket.rb, lib/mongrel2/xmlrequest.rb,
27
+ spec/lib/helpers.rb, spec/mongrel2/handler_spec.rb,
28
+ spec/mongrel2/logging_spec.rb, spec/mongrel2/mixins_spec.rb,
29
+ spec/mongrel2_spec.rb:
30
+ Convert to Loggability for logging.
31
+ [0da53476f796]
32
+
33
+ 2012-04-25 Michael Granger <ged@FaerieMUD.org>
34
+
35
+ * bin/m2sh.rb:
36
+ Add an option to m2sh.rb to set the m2 port on the fly
37
+ [0a0238b4c238] [github/master]
38
+
1
39
  2012-04-23 Michael Granger <ged@FaerieMUD.org>
2
40
 
41
+ * .hgtags:
42
+ Added tag v0.21.0 for changeset 84fe60846300
43
+ [bb658253dfe9]
44
+
45
+ * .hgsigs:
46
+ Added signature for changeset d7c540c7a114
47
+ [84fe60846300] [v0.21.0]
48
+
49
+ * .rvm.gems:
50
+ Bumped hoe-deveiate in the dev gemset
51
+ [d7c540c7a114]
52
+
53
+ * History.rdoc, lib/mongrel2.rb:
54
+ Bump the minor version, update history.
55
+ [0ecd9e4d21ee]
56
+
3
57
  * Rakefile:
4
58
  Activate deveiate Hoe plugin
5
- [4b74d9363949] [github/master, tip]
59
+ [4b74d9363949]
6
60
 
7
61
  * lib/mongrel2/handler.rb:
8
62
  Log the request at INFO, too.
data/History.rdoc CHANGED
@@ -1,3 +1,15 @@
1
+ == v0.22.1 [2012-05-07] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ Fix loggability dependency version.
4
+
5
+
6
+ == v0.22.0 [2012-05-07] Michael Granger <ged@FaerieMUD.org>
7
+
8
+ - Convert to Loggability for logging.
9
+ - Add an option to bin/m2sh.rb to rewrite the mongrel2 port of a host
10
+ on the fly at startup.
11
+
12
+
1
13
  == v0.21.0 [2012-04-23] Michael Granger <ged@FaerieMUD.org>
2
14
 
3
15
  - Rename the defaults for Mongrel2::Config.
data/Manifest.txt CHANGED
@@ -42,8 +42,6 @@ lib/mongrel2/handler.rb
42
42
  lib/mongrel2/httprequest.rb
43
43
  lib/mongrel2/httpresponse.rb
44
44
  lib/mongrel2/jsonrequest.rb
45
- lib/mongrel2/logging.rb
46
- lib/mongrel2/mixins.rb
47
45
  lib/mongrel2/request.rb
48
46
  lib/mongrel2/response.rb
49
47
  lib/mongrel2/table.rb
@@ -71,8 +69,6 @@ spec/mongrel2/control_spec.rb
71
69
  spec/mongrel2/handler_spec.rb
72
70
  spec/mongrel2/httprequest_spec.rb
73
71
  spec/mongrel2/httpresponse_spec.rb
74
- spec/mongrel2/logging_spec.rb
75
- spec/mongrel2/mixins_spec.rb
76
72
  spec/mongrel2/request_spec.rb
77
73
  spec/mongrel2/response_spec.rb
78
74
  spec/mongrel2/table_spec.rb
data/Rakefile CHANGED
@@ -33,7 +33,8 @@ hoespec = Hoe.spec 'mongrel2' do
33
33
  self.dependency 'yajl-ruby', '~> 1.0'
34
34
  self.dependency 'trollop', '~> 1.16'
35
35
  self.dependency 'sysexits', '~> 1.0'
36
- self.dependency 'zmq', '~> 2.1.4'
36
+ self.dependency 'zmq', '~> 2.1'
37
+ self.dependency 'loggability','~> 0.0'
37
38
 
38
39
  self.dependency 'configurability', '~> 1.0', :developer
39
40
  self.dependency 'simplecov', '~> 0.6', :developer
data/bin/m2sh.rb CHANGED
@@ -5,6 +5,7 @@ require 'pathname'
5
5
  require 'shellwords'
6
6
  require 'fileutils'
7
7
  require 'tnetstring'
8
+ require 'loggability'
8
9
 
9
10
  require 'trollop'
10
11
  require 'highline'
@@ -45,11 +46,15 @@ require 'mongrel2/config'
45
46
  # mongrel2.
46
47
  #
47
48
  class Mongrel2::M2SHCommand
48
- extend ::Sysexits
49
+ extend ::Sysexits,
50
+ Loggability
49
51
  include Sysexits,
50
- Mongrel2::Loggable,
51
52
  Mongrel2::Constants
52
53
 
54
+ # Loggability API -- set up logging under the 'strelka' log host
55
+ log_to :mongrel2
56
+
57
+
53
58
  # Make a HighLine color scheme
54
59
  COLOR_SCHEME = HighLine::ColorScheme.new do |scheme|
55
60
  scheme[:header] = [ :bold, :yellow ]
@@ -125,8 +130,8 @@ class Mongrel2::M2SHCommand
125
130
  exit :ok
126
131
 
127
132
  rescue => err
128
- Mongrel2.logger.fatal "Oops: %s: %s" % [ err.class.name, err.message ]
129
- Mongrel2.logger.debug { ' ' + err.backtrace.join("\n ") }
133
+ self.fatal "Oops: %s: %s" % [ err.class.name, err.message ]
134
+ self.debug { ' ' + err.backtrace.join("\n ") }
130
135
 
131
136
  exit :software_error
132
137
  end
@@ -167,7 +172,7 @@ class Mongrel2::M2SHCommand
167
172
  default_configdb = Mongrel2::DEFAULT_CONFIG_URI
168
173
 
169
174
  # Make a list of the log level names and the available commands
170
- loglevels = Mongrel2::Logging::LOG_LEVELS.
175
+ loglevels = Loggability::LOG_LEVELS.
171
176
  sort_by {|name,lvl| lvl }.
172
177
  collect {|name,lvl| name.to_s }.
173
178
  join( ', ' )
@@ -184,12 +189,14 @@ class Mongrel2::M2SHCommand
184
189
  opt :config, "Specify the configfile to use.",
185
190
  :default => DEFAULT_CONFIG_URI
186
191
  opt :sudo, "Use 'sudo' to run the mongrel2 server."
192
+ opt :port, "Reset the server port to <i> before starting it.",
193
+ :type => :integer
187
194
  text ''
188
195
 
189
196
  text 'Other Options:'
190
197
  opt :debug, "Turn debugging on. Also sets the --loglevel to 'debug'."
191
198
  opt :loglevel, "Set the logging level. Must be one of: #{loglevels}",
192
- :default => Mongrel2::Logging::LOG_LEVEL_NAMES[ Mongrel2.logger.level ]
199
+ :default => Mongrel2.logger.level.to_s
193
200
  end
194
201
  end
195
202
 
@@ -204,16 +211,16 @@ class Mongrel2::M2SHCommand
204
211
  ### Create a new instance of the command and set it up with the given
205
212
  ### +options+.
206
213
  def initialize( options )
207
- Mongrel2.logger.formatter = Mongrel2::Logging::ColorFormatter.new( Mongrel2.logger )
214
+ Loggability.format_as( :color ) if $stderr.tty?
208
215
  @options = options
209
216
  @shellmode = false
210
217
 
211
218
  if @options.debug
212
219
  $DEBUG = true
213
220
  $VERBOSE = true
214
- Mongrel2.logger.level = Logger::DEBUG
221
+ Loggability.level = Logger::DEBUG
215
222
  elsif @options.loglevel
216
- Mongrel2.logger.level = Mongrel2::Logging::LOG_LEVELS[ @options.loglevel ]
223
+ Loggability.level = @options.loglevel
217
224
  end
218
225
 
219
226
  Mongrel2::Config.configure( :configdb => @options.config )
@@ -498,6 +505,12 @@ class Mongrel2::M2SHCommand
498
505
  server = find_server( args.shift )
499
506
  mongrel2 = ENV['MONGREL2'] || 'mongrel2'
500
507
 
508
+ if options.port
509
+ message "Resetting %s server's port to %d" % [ server.name, options.port ]
510
+ server.port = options.port
511
+ server.save
512
+ end
513
+
501
514
  # Run the command, waiting for it to finish if invoked from shell mode, or
502
515
  # execing it if not.
503
516
  cmd = [ mongrel2, Mongrel2::Config.dbname.to_s, server.uuid ]
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'logger'
3
+ require 'loggability'
4
4
  require 'mongrel2/config'
5
5
  require 'mongrel2/handler'
6
6
 
@@ -23,8 +23,8 @@ end # class HelloWorldHandler
23
23
  configdb = ARGV.shift || 'examples.sqlite'
24
24
 
25
25
  # Log to a file instead of STDERR for a bit more speed.
26
- # Mongrel2.log = Logger.new( 'hello-world.log' )
27
- Mongrel2.log.level = Logger::DEBUG
26
+ # Loggability.output_to( 'hello-world.log' )
27
+ Loggability.level = :debug
28
28
 
29
29
  # Point to the config database, which will cause the handler to use
30
30
  # its ID to look up its own socket info.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'pathname'
4
- require 'logger'
4
+ require 'loggability'
5
5
  require 'mongrel2/config'
6
6
  require 'mongrel2/handler'
7
7
 
@@ -38,8 +38,8 @@ class RequestDumper < Mongrel2::Handler
38
38
 
39
39
  end # class RequestDumper
40
40
 
41
- Mongrel2.log.level = Logger::DEBUG
42
- Inversion.log.level = Logger::INFO
41
+ Loggability.level = :debug
42
+ Loggability[ Inversion ].level = :info
43
43
 
44
44
  # Point to the config database, which will cause the handler to use
45
45
  # its ID to look up its own socket info.
data/examples/ws-echo.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: utf-8
3
3
 
4
+ require 'loggability'
4
5
  require 'pathname'
5
- require 'logger'
6
6
  require 'mongrel2/config'
7
7
  require 'mongrel2/logging'
8
8
  require 'mongrel2/handler'
@@ -241,8 +241,8 @@ class WebSocketEchoServer < Mongrel2::Handler
241
241
 
242
242
  end # class RequestDumper
243
243
 
244
- Mongrel2.log.level = $DEBUG||$VERBOSE ? Logger::DEBUG : Logger::INFO
245
- Mongrel2.log.formatter = Mongrel2::Logging::ColorFormatter.new( Mongrel2.log ) if $stdin.tty?
244
+ Loggability.level = $DEBUG||$VERBOSE ? :debug : :info
245
+ Loggability.format_as( :color ) if $stdin.tty?
246
246
 
247
247
  # Point to the config database, which will cause the handler to use
248
248
  # its ID to look up its own socket info.
data/lib/mongrel2.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'loggability'
3
4
  require 'zmq'
4
5
 
5
6
  #
@@ -10,18 +11,20 @@ require 'zmq'
10
11
  # * Michael Granger <ged@FaerieMUD.org>
11
12
  #
12
13
  module Mongrel2
14
+ extend Loggability
15
+
16
+ # Loggability API -- set up Mongrel2 as a log host
17
+ log_as :mongrel2
18
+
13
19
 
14
20
  abort "\n\n>>> Mongrel2 requires Ruby 1.9.2 or later. <<<\n\n" if RUBY_VERSION < '1.9.2'
15
21
 
16
22
  # Library version constant
17
- VERSION = '0.21.0'
23
+ VERSION = '0.22.1'
18
24
 
19
25
  # Version-control revision constant
20
- REVISION = %q$Revision: 0ecd9e4d21ee $
21
-
26
+ REVISION = %q$Revision: c68ca662121f $
22
27
 
23
- require 'mongrel2/logging'
24
- extend Mongrel2::Logging
25
28
 
26
29
  require 'mongrel2/constants'
27
30
  include Mongrel2::Constants
@@ -42,7 +45,7 @@ module Mongrel2
42
45
  ### Fetch the ZMQ::Context for sockets, creating it if necessary.
43
46
  def self::zmq_context
44
47
  if @zmq_ctx.nil?
45
- Mongrel2.log.info "Using 0MQ %d.%d.%d" % ZMQ.version
48
+ self.log.info "Using 0MQ %d.%d.%d" % ZMQ.version
46
49
  @zmq_ctx = ZMQ::Context.new
47
50
  end
48
51
 
@@ -5,6 +5,7 @@ require 'yaml'
5
5
  require 'pathname'
6
6
  require 'uri'
7
7
  require 'tnetstring'
8
+ require 'loggability'
8
9
 
9
10
  require 'sequel'
10
11
 
@@ -26,26 +27,29 @@ end
26
27
 
27
28
 
28
29
  require 'mongrel2' unless defined?( Mongrel2 )
29
- require 'mongrel2/mixins'
30
30
 
31
31
  module Mongrel2
32
32
 
33
33
  # The base Mongrel2 database-backed configuration class. It's a subclass of Sequel::Model, so
34
- # you'll first need to be familiar with Sequel (http://sequel.rubyforge.org/) and
35
- # especially its Sequel::Model ORM.
34
+ # you'll first need to be familiar with Sequel (http://sequel.rubyforge.org/) and
35
+ # especially its Sequel::Model ORM.
36
36
  #
37
- # You will also probably want to refer to the Sequel::Plugins documentation for the
37
+ # You will also probably want to refer to the Sequel::Plugins documentation for the
38
38
  # validation_helpers[http://sequel.rubyforge.org/rdoc-plugins/classes/Sequel/Plugins/ValidationHelpers.html]
39
- # and
39
+ # and
40
40
  # subclasses[http://sequel.rubyforge.org/rdoc-plugins/classes/Sequel/Plugins/Subclasses.html]
41
41
  # plugins.
42
- #
42
+ #
43
43
  # == References
44
44
  # * http://mongrel2.org/static/mongrel2-manual.html#x1-250003.4
45
45
  #
46
46
  class Config < Sequel::Model
47
- include Mongrel2::Loggable
47
+ extend Loggability
48
+
49
+ # Loggability API -- set up logging under the 'mongrel2' log host
50
+ log_to :mongrel2
48
51
 
52
+ # Sequel API -- load some plugins
49
53
  plugin :validation_helpers
50
54
  plugin :subclasses
51
55
  plugin :json_serializer
@@ -129,9 +133,9 @@ module Mongrel2
129
133
  end
130
134
 
131
135
  if self == Mongrel2::Config
132
- Mongrel2.log.debug "Resetting database connection for %d config classes to: %p" %
136
+ self.log.debug "Resetting database connection for %d config classes to: %p" %
133
137
  [ self.descendents.length, newdb ]
134
- newdb.logger = Mongrel2.logger
138
+ newdb.logger = Loggability[ Mongrel2 ].proxy_for( newdb )
135
139
  newdb.sql_log_level = :debug
136
140
 
137
141
  self.descendents.each {|subclass| subclass.db = newdb }
@@ -191,7 +195,7 @@ module Mongrel2
191
195
  sql = self.load_config_schema
192
196
  mimetypes_sql = self.load_mimetypes_sql
193
197
 
194
- Mongrel2.log.warn "Installing config schema."
198
+ self.log.warn "Installing config schema."
195
199
 
196
200
  self.db.execute_ddl( sql )
197
201
  self.db.run( mimetypes_sql )
@@ -1,17 +1,22 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'loggability'
4
+
3
5
  require 'mongrel2' unless defined?( Mongrel2 )
4
6
  require 'mongrel2/config' unless defined?( Mongrel2::Config )
5
7
 
6
8
  # See DSL.rdoc for details on how to use this mixin.
7
9
  module Mongrel2::Config::DSL
8
10
 
9
-
10
11
  # A decorator object that provides the DSL-ish interface to the various Config
11
12
  # objects. It derives its interface on the fly from columns of the class it's
12
13
  # created with and a DSLMethods mixin if the target class defines one.
13
14
  class Adapter
14
- include Mongrel2::Loggable
15
+ extend Loggability
16
+
17
+ # Loggability API -- set up logging under the 'mongrel2' log host
18
+ log_to :mongrel2
19
+
15
20
 
16
21
  ### Create an instance of the specified +targetclass+ using the specified +opts+
17
22
  ### as initial values. The first pair of +opts+ will be used in the filter to
@@ -30,7 +30,7 @@ class Mongrel2::Config::Host < Mongrel2::Config( :host )
30
30
  ### Add a Mongrel2::Config::Route to the Host object.
31
31
  def route( path, target, opts={} )
32
32
  self.target.save
33
- Mongrel2.log.debug "Route %s -> %p [%p]" % [ path, target, opts ]
33
+ self.log.debug "Route %s -> %p [%p]" % [ path, target, opts ]
34
34
 
35
35
  args = { :path => path, :target => target }
36
36
  args.merge!( opts )
@@ -87,11 +87,11 @@ class Mongrel2::Config::Host < Mongrel2::Config( :host )
87
87
 
88
88
  existing = Mongrel2::Config::Handler.filter( :send_ident => send_ident )
89
89
  unless existing.select( :id ).empty?
90
- Mongrel2.log.debug "Dropping existing %p handler." % [ send_ident ]
90
+ self.log.debug "Dropping existing %p handler." % [ send_ident ]
91
91
  existing.delete
92
92
  end
93
93
 
94
- Mongrel2.log.debug "Creating handler with options: %p" % [ options ]
94
+ self.log.debug "Creating handler with options: %p" % [ options ]
95
95
  return Mongrel2::Config::Handler.create( options )
96
96
  end
97
97
 
@@ -41,16 +41,16 @@ class Mongrel2::Config::Server < Mongrel2::Config( :server )
41
41
  def control_socket_uri
42
42
  # Find the control socket relative to the server's chroot
43
43
  csock_uri = Mongrel2::Config.settings[:control_port] || DEFAULT_CONTROL_SOCKET
44
- Mongrel2.log.debug "Chrooted control socket uri is: %p" % [ csock_uri ]
44
+ self.log.debug "Chrooted control socket uri is: %p" % [ csock_uri ]
45
45
 
46
46
  scheme, sock_path = csock_uri.split( '://', 2 )
47
- Mongrel2.log.debug " chrooted socket path is: %p" % [ sock_path ]
47
+ self.log.debug " chrooted socket path is: %p" % [ sock_path ]
48
48
 
49
49
  csock_path = Pathname( self.chroot ) + sock_path
50
- Mongrel2.log.debug " fully-qualified path is: %p" % [ csock_path ]
50
+ self.log.debug " fully-qualified path is: %p" % [ csock_path ]
51
51
  csock_uri = "%s://%s" % [ scheme, csock_path ]
52
52
 
53
- Mongrel2.log.debug " control socket URI is: %p" % [ csock_uri ]
53
+ self.log.debug " control socket URI is: %p" % [ csock_uri ]
54
54
  return csock_uri
55
55
  end
56
56
 
@@ -91,7 +91,7 @@ class Mongrel2::Config::Server < Mongrel2::Config( :server )
91
91
  def host( name, &block )
92
92
  self.target.save( :validate => false )
93
93
 
94
- Mongrel2.log.debug "Host [%s] (block: %p)" % [ name, block ]
94
+ self.log.debug "Host [%s] (block: %p)" % [ name, block ]
95
95
  adapter = Mongrel2::Config::DSL::Adapter.new( Mongrel2::Config::Host, name: name )
96
96
  adapter.target.matching = name
97
97
  adapter.instance_eval( &block ) if block
@@ -104,7 +104,7 @@ class Mongrel2::Config::Server < Mongrel2::Config( :server )
104
104
  def filter( path, settings={} )
105
105
  self.target.save( :validate => false )
106
106
 
107
- Mongrel2.log.debug "Filter [%s]: %p" % [ path, settings ]
107
+ self.log.debug "Filter [%s]: %p" % [ path, settings ]
108
108
  self.target.add_filter( name: path, settings: settings )
109
109
  end
110
110