Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

New Mongrel.log is verified working for Mongrel Handler, Rails and Merb.

git-svn-id: svn://rubyforge.org/var/svn/mongrel/trunk@916 19e92222-5c0b-0410-8929-a290d50e31e9
  • Loading branch information...
commit 79948cb846f06a750877e27d6b849ee57cac269f 1 parent 47d6792
wayneeseguin authored
40 bin/mongrel_rails
@@ -75,49 +75,49 @@ module Mongrel
75 75 def run
76 76 if @generate
77 77 @generate = File.expand_path(@generate)
78   - log(:error, "** Writing config to \"#@generate\".")
  78 + Mongrel.log(:error, "** Writing config to \"#@generate\".")
79 79 open(@generate, "w") {|f| f.write(settings.to_yaml) }
80   - log(:error, "** Finished. Run \"mongrel_rails start -C #@generate\" to use the config file.")
  80 + Mongrel.log(:error, "** Finished. Run \"mongrel_rails start -C #@generate\" to use the config file.")
81 81 exit 0
82 82 end
83 83
84 84 config = Mongrel::Rails::RailsConfigurator.new(settings) do
85 85 if defaults[:daemon]
86 86 if File.exist? defaults[:pid_file]
87   - log "!!! PID file #{defaults[:pid_file]} already exists. Mongrel could be running already. Check your #{defaults[:log_file]} for errors."
88   - log "!!! Exiting with error. You must stop mongrel and clear the .pid before I'll attempt a start."
  87 + Mongrel.error(:info, "!!! PID file #{defaults[:pid_file]} already exists. Mongrel could be running already. Check your #{defaults[:log_file]} for errors.")
  88 + Mongrel.log(:error, "!!! Exiting with error. You must stop mongrel and clear the .pid before I'll attempt a start.")
89 89 exit 1
90 90 end
91 91
92 92 daemonize
93   - log "Daemonized, any open files are closed. Look at #{defaults[:pid_file]} and #{defaults[:log_file]} for info."
94   - log "Settings loaded from #{@config_file} (they override command line)." if @config_file
  93 + Mongrel.log(:info, "Daemonized, any open files are closed. Look at #{defaults[:pid_file]} and #{defaults[:log_file]} for info.")
  94 + Mongrel.log(:info, "Settings loaded from #{@config_file} (they override command line).") if @config_file
95 95 end
96 96
97   - log "Starting Mongrel listening at #{defaults[:host]}:#{defaults[:port]}"
  97 + Mongrel.log(:info, "Starting Mongrel listening at #{defaults[:host]}:#{defaults[:port]}")
98 98
99 99 listener do
100 100 mime = {}
101 101 if defaults[:mime_map]
102   - log "Loading additional MIME types from #{defaults[:mime_map]}"
  102 + Mongrel.log(:info, "Loading additional MIME types from #{defaults[:mime_map]}")
103 103 mime = load_mime_map(defaults[:mime_map], mime)
104 104 end
105 105
106 106 if defaults[:debug]
107   - log "Installing debugging prefixed filters. Look in log/mongrel_debug for the files."
  107 + Mongrel.log(:info, "Installing debugging prefixed filters. Look in log/mongrel_debug for the files.")
108 108 debug "/"
109 109 end
110 110
111   - log "Starting Rails with #{defaults[:environment]} environment..."
112   - log "Mounting Rails at #{defaults[:prefix]}..." if defaults[:prefix]
  111 + Mongrel.log(:info, "Starting Rails with #{defaults[:environment]} environment...")
  112 + Mongrel.log(:info, "Mounting Rails at #{defaults[:prefix]}...") if defaults[:prefix]
113 113 uri defaults[:prefix] || "/", :handler => rails(:mime => mime, :prefix => defaults[:prefix])
114   - log "Rails loaded."
  114 + Mongrel.log(:info, "Rails loaded.")
115 115
116   - log "Loading any Rails specific GemPlugins"
  116 + Mongrel.log(:info, "Loading any Rails specific GemPlugins" )
117 117 load_plugins
118 118
119 119 if defaults[:config_script]
120   - log "Loading #{defaults[:config_script]} external config script"
  120 + Mongrel.log(:info, "Loading #{defaults[:config_script]} external config script")
121 121 run_config(defaults[:config_script])
122 122 end
123 123
@@ -126,12 +126,12 @@ module Mongrel
126 126 end
127 127
128 128 config.run
129   - config.log "Mongrel #{Mongrel::Const::MONGREL_VERSION} available at #{@address}:#{@port}"
  129 + Mongrel.log(:info, "Mongrel #{Mongrel::Const::MONGREL_VERSION} available at #{@address}:#{@port}")
130 130
131 131 if config.defaults[:daemon]
132 132 config.write_pid_file
133 133 else
134   - config.log "Use CTRL-C to stop."
  134 + Mongrel.log(:info, "Use CTRL-C to stop.")
135 135 end
136 136
137 137 config.join
@@ -139,18 +139,18 @@ module Mongrel
139 139 if config.needs_restart
140 140 unless RUBY_PLATFORM =~ /djgpp|(cyg|ms|bcc)win|mingw/
141 141 cmd = "ruby #{__FILE__} start #{original_args.join(' ')}"
142   - config.log "Restarting with arguments: #{cmd}"
  142 + Mongrel.log(:info, "Restarting with arguments: #{cmd}")
143 143 config.stop(false, true)
144 144 config.remove_pid_file
145 145
146 146 if config.defaults[:daemon]
147 147 system cmd
148 148 else
149   - log(:error, "Can't restart unless in daemon mode.")
  149 + Mongrel.log(:error, "Can't restart unless in daemon mode.")
150 150 exit 1
151 151 end
152 152 else
153   - config.log "Win32 does not support restarts. Exiting."
  153 + Mongrel.log(:info, "Win32 does not support restarts. Exiting.")
154 154 end
155 155 end
156 156 end
@@ -160,7 +160,7 @@ module Mongrel
160 160 begin
161 161 settings = YAML.load_file(@config_file)
162 162 ensure
163   - log(:error, "** Loading settings from #{@config_file} (they override command line)." unless @daemon || settings[:daemon] )
  163 + Mongrel.log(:error, "** Loading settings from #{@config_file} (they override command line).") unless @daemon || settings[:daemon]
164 164 end
165 165
166 166 settings[:includes] ||= ["mongrel"]
6 examples/builder.rb
@@ -4,9 +4,9 @@ class TestPlugin < GemPlugin::Plugin "/handlers"
4 4 include Mongrel::HttpHandlerPlugin
5 5
6 6 def process(request, response)
7   - log(:error, "My options are: #{options.inspect}")
8   - log(:error, "Request Was:")
9   - log(:error, request.params.to_yaml)
  7 + Mongrel.log(:error, "My options are: #{options.inspect}")
  8 + Mongrel.log(:error, "Request Was:")
  9 + Mongrel.log(:error, request.params.to_yaml)
10 10 end
11 11 end
12 12
2  ext/http11/http11.c
@@ -391,7 +391,7 @@ void Init_http11()
391 391 DEF_GLOBAL(server_protocol, "SERVER_PROTOCOL");
392 392 DEF_GLOBAL(server_protocol_value, "HTTP/1.1");
393 393 DEF_GLOBAL(http_host, "HTTP_HOST");
394   - DEF_GLOBAL(mongrel_version, "Mongrel 1.1.1"); /* XXX Why is this defined here? */
  394 + DEF_GLOBAL(mongrel_version, "Mongrel 1.1.2"); /* XXX Why is this defined here? */
395 395 DEF_GLOBAL(server_software, "SERVER_SOFTWARE");
396 396 DEF_GLOBAL(port_80, "80");
397 397
32 lib/mongrel.rb
... ... @@ -1,3 +1,4 @@
  1 +# Ruby
1 2 require 'socket'
2 3 require 'tempfile'
3 4 require 'yaml'
@@ -6,10 +7,15 @@
6 7 require 'uri'
7 8 require 'stringio'
8 9
  10 +# Ensure working require
9 11 require 'mongrel/gems'
10 12
  13 +# TODO: Only require these for RUBY_VERSION <= 1.8.6
  14 +# and only for platforms that require it, exclusive matching
  15 +if !RUBY_PLATFORM.match(/java|mswin/) && !RUBY_VERSION.match(/1\.8\.\d/)
11 16 Mongrel::Gems.require 'cgi_multipart_eof_fix'
12 17 Mongrel::Gems.require 'fastthread'
  18 +end
13 19 require 'thread'
14 20
15 21 require 'http11'
@@ -183,23 +189,23 @@ def process_client(client)
183 189 rescue EOFError,Errno::ECONNRESET,Errno::EPIPE,Errno::EINVAL,Errno::EBADF
184 190 client.close rescue nil
185 191 rescue HttpParserError => e
186   - log(:error, "#{Time.now.httpdate}: HTTP parse error, malformed request (#{params[Const::HTTP_X_FORWARDED_FOR] || client.peeraddr.last}): #{e.inspect}")
187   - log(:error, "#{Time.now.httpdate}: REQUEST DATA: #{data.inspect}\n---\nPARAMS: #{params.inspect}\n---\n")
  192 + Mongrel.log(:error, "#{Time.now.httpdate}: HTTP parse error, malformed request (#{params[Const::HTTP_X_FORWARDED_FOR] || client.peeraddr.last}): #{e.inspect}")
  193 + Mongrel.log(:error, "#{Time.now.httpdate}: REQUEST DATA: #{data.inspect}\n---\nPARAMS: #{params.inspect}\n---\n")
188 194 # http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4
189 195 client.write(Const::ERROR_400_RESPONSE)
190 196 rescue Errno::EMFILE
191 197 reap_dead_workers('too many files')
192 198 rescue Object => e
193   - log(:error, "#{Time.now.httpdate}: Read error: #{e.inspect}")
194   - log(:error, e.backtrace.join("\n"))
  199 + Mongrel.log(:error, "#{Time.now.httpdate}: Read error: #{e.inspect}")
  200 + Mongrel.log(:error, e.backtrace.join("\n"))
195 201 ensure
196 202 begin
197 203 client.close
198 204 rescue IOError
199 205 # Already closed
200 206 rescue Object => e
201   - log(:error, "#{Time.now.httpdate}: Client error: #{e.inspect}")
202   - log(:error, e.backtrace.join("\n"))
  207 + Mongrel.log(:error, "#{Time.now.httpdate}: Client error: #{e.inspect}")
  208 + Mongrel.log(:error, e.backtrace.join("\n"))
203 209 end
204 210 request.body.delete if request and request.body.class == Tempfile
205 211 end
@@ -211,14 +217,14 @@ def process_client(client)
211 217 # after the reap is done. It only runs if there are workers to reap.
212 218 def reap_dead_workers(reason='unknown')
213 219 if @workers.list.length > 0
214   - log(:error, "#{Time.now.httpdate}: Reaping #{@workers.list.length} threads for slow workers because of '#{reason}'")
  220 + Mongrel.log(:error, "#{Time.now.httpdate}: Reaping #{@workers.list.length} threads for slow workers because of '#{reason}'")
215 221 error_msg = "#{Time.now.httpdate}: Mongrel timed out this thread: #{reason}"
216 222 mark = Time.now
217 223 @workers.list.each do |worker|
218 224 worker[:started_on] = Time.now if not worker[:started_on]
219 225
220 226 if mark - worker[:started_on] > @timeout + @throttle
221   - log(:error, "#{Time.now.httpdate}: Thread #{worker.inspect} is too old, killing.")
  227 + Mongrel.log(:error, "#{Time.now.httpdate}: Thread #{worker.inspect} is too old, killing.")
222 228 worker.raise(TimeoutError.new(error_msg))
223 229 end
224 230 end
@@ -233,7 +239,7 @@ def reap_dead_workers(reason='unknown')
233 239 # that much longer.
234 240 def graceful_shutdown
235 241 while reap_dead_workers("shutdown") > 0
236   - log(:error, "#{Time.now.httpdate}: Waiting for #{@workers.list.length} requests to finish, could take #{@timeout + @throttle} seconds.")
  242 + Mongrel.log(:error, "#{Time.now.httpdate}: Waiting for #{@workers.list.length} requests to finish, could take #{@timeout + @throttle} seconds.")
237 243 sleep @timeout / 10
238 244 end
239 245 end
@@ -279,7 +285,7 @@ def run
279 285 worker_list = @workers.list
280 286
281 287 if worker_list.length >= @num_processors
282   - log(:error, "#{Time.now.httpdate}: Server overloaded with #{worker_list.length} processors (#@num_processors max). Dropping connection.")
  288 + Mongrel.log(:error, "#{Time.now.httpdate}: Server overloaded with #{worker_list.length} processors (#@num_processors max). Dropping connection.")
283 289 client.close rescue nil
284 290 reap_dead_workers("max processors")
285 291 else
@@ -298,14 +304,14 @@ def run
298 304 # client closed the socket even before accept
299 305 client.close rescue nil
300 306 rescue Object => e
301   - log(:error, "#{Time.now.httpdate}: Unhandled listen loop exception #{e.inspect}.")
302   - log(:error, e.backtrace.join("\n"))
  307 + Mongrel.log(:error, "#{Time.now.httpdate}: Unhandled listen loop exception #{e.inspect}.")
  308 + Mongrel.log(:error, e.backtrace.join("\n"))
303 309 end
304 310 end
305 311 graceful_shutdown
306 312 ensure
307 313 @socket.close
308   - # log(:error, "#{Time.now.httpdate}: Closed socket.")
  314 + # Mongrel.log(:error, "#{Time.now.httpdate}: Closed socket.")
309 315 end
310 316 end
311 317
12 lib/mongrel/command.rb
@@ -55,14 +55,14 @@ def initialize(options={})
55 55 # I need to add my own -h definition to prevent the -h by default from exiting.
56 56 @opt.on_tail("-h", "--help", "Show this message") do
57 57 @done_validating = true
58   - puts @opt
  58 + Mongrel.log(:info, @opt)
59 59 end
60 60
61 61 # I need to add my own -v definition to prevent the -v from exiting by default as well.
62 62 @opt.on_tail("--version", "Show version") do
63 63 @done_validating = true
64 64 if VERSION
65   - puts "Version #{Mongrel::Const::MONGREL_VERSION}"
  65 + Mongrel.log(:info, "Version #{Mongrel::Const::MONGREL_VERSION}")
66 66 end
67 67 end
68 68
@@ -155,17 +155,17 @@ def commands
155 155
156 156 # Prints a list of available commands.
157 157 def print_command_list
158   - puts "#{Mongrel::Command::BANNER}\nAvailable commands are:\n\n"
  158 + Mongrel.log(:info, "#{Mongrel::Command::BANNER}\nAvailable commands are:\n\n")
159 159
160 160 self.commands.each do |name|
161 161 if /mongrel::/ =~ name
162 162 name = name[9 .. -1]
163 163 end
164 164
165   - puts " - #{name[1 .. -1]}\n"
  165 + Mongrel.log(:info, " - #{name[1 .. -1]}\n")
166 166 end
167 167
168   - puts "\nEach command takes -h as an option to get help."
  168 + Mongrel.log(:info, "\nEach command takes -h as an option to get help.")
169 169
170 170 end
171 171
@@ -180,7 +180,7 @@ def run(args)
180 180 print_command_list
181 181 return true
182 182 elsif cmd_name == "--version"
183   - puts "Mongrel Web Server #{Mongrel::Const::MONGREL_VERSION}"
  183 + Mongrel.log(:info, "Mongrel Web Server #{Mongrel::Const::MONGREL_VERSION}")
184 184 return true
185 185 end
186 186
30 lib/mongrel/configurator.rb
@@ -59,18 +59,18 @@ def change_privilege(user, group)
59 59 target_gid = Etc.getgrnam(group).gid if group
60 60
61 61 if uid != target_uid or gid != target_gid
62   - log(:info, "Initiating groups for #{user.inspect}:#{group.inspect}.")
  62 + Mongrel.log(:info, "Initiating groups for #{user.inspect}:#{group.inspect}.")
63 63 Process.initgroups(user, target_gid)
64 64
65   - log(:info, "Changing group to #{group.inspect}.")
  65 + Mongrel.log(:info, "Changing group to #{group.inspect}.")
66 66 Process::GID.change_privilege(target_gid)
67 67
68   - log(:info, "Changing user to #{user.inspect}." )
  68 + Mongrel.log(:info, "Changing user to #{user.inspect}." )
69 69 Process::UID.change_privilege(target_uid)
70 70 end
71 71 rescue Errno::EPERM => e
72   - log(:critical, "Couldn't change user and group to #{user.inspect}:#{group.inspect}: #{e.to_s}.")
73   - log(:critical, "Mongrel failed to start.")
  72 + Mongrel.log(:critical, "Couldn't change user and group to #{user.inspect}:#{group.inspect}: #{e.to_s}.")
  73 + Mongrel.log(:critical, "Mongrel failed to start.")
74 74 exit 1
75 75 end
76 76 end
@@ -82,7 +82,7 @@ def remove_pid_file
82 82 # Writes the PID file if we're not on Windows.
83 83 def write_pid_file
84 84 unless RUBY_PLATFORM =~ /djgpp|(cyg|ms|bcc)win|mingw/
85   - log(:info, "Writing PID file to #{@pid_file}")
  85 + Mongrel.log(:info, "Writing PID file to #{@pid_file}")
86 86 open(@pid_file,"w") {|f| f.write(Process.pid) }
87 87 open(@pid_file,"w") do |f|
88 88 f.write(Process.pid)
@@ -192,7 +192,7 @@ def daemonize(options={})
192 192 if logfile[0].chr != "/"
193 193 logfile = File.join(ops[:cwd],logfile)
194 194 if not File.exist?(File.dirname(logfile))
195   - log(:critical, "!!! Log file directory not found at full path #{File.dirname(logfile)}. Update your configuration to use a full path.")
  195 + Mongrel.log(:critical, "!!! Log file directory not found at full path #{File.dirname(logfile)}. Update your configuration to use a full path.")
196 196 exit 1
197 197 end
198 198 end
@@ -203,7 +203,7 @@ def daemonize(options={})
203 203 Dir.chdir(ops[:cwd])
204 204
205 205 else
206   - log(:warning, "WARNING: Win32 does not support daemon mode.")
  206 + Mongrel.log(:warning, "WARNING: Win32 does not support daemon mode.")
207 207 end
208 208 end
209 209
@@ -249,7 +249,7 @@ def load_mime_map(file, mime={})
249 249 mime = load_yaml(file, mime)
250 250
251 251 # check all the mime types to make sure they are the right format
252   - mime.each {|k,v| log(:warning, "WARNING: MIME type #{k} must start with '.'") if k.index(".") != 0 }
  252 + mime.each {|k,v| Mongrel.log(:warning, "WARNING: MIME type #{k} must start with '.'") if k.index(".") != 0 }
253 253
254 254 return mime
255 255 end
@@ -361,22 +361,22 @@ def setup_signals(options={})
361 361 ops = resolve_defaults(options)
362 362
363 363 # forced shutdown, even if previously restarted (actually just like TERM but for CTRL-C)
364   - trap("INT") { log(:notice, "INT signal received."); stop(false) }
  364 + trap("INT") { Mongrel.log(:notice, "INT signal received."); stop(false) }
365 365
366 366 # always clean up the pid file
367 367 at_exit { remove_pid_file }
368 368
369 369 unless RUBY_PLATFORM =~ /djgpp|(cyg|ms|bcc)win|mingw/
370 370 # graceful shutdown
371   - trap("TERM") { log(:notice, "TERM signal received."); stop }
  371 + trap("TERM") { Mongrel.log(:notice, "TERM signal received."); stop }
372 372 # debug mode
373   - trap("USR1") { log(:notice, "USR1 received, toggling $mongrel_debug_client to #{!$mongrel_debug_client}"); $mongrel_debug_client = !$mongrel_debug_client }
  373 + trap("USR1") { Mongrel.log(:notice, "USR1 received, toggling $mongrel_debug_client to #{!$mongrel_debug_client}"); $mongrel_debug_client = !$mongrel_debug_client }
374 374 # restart
375   - trap("USR2") { log(:notice, "USR2 signal received."); stop(true) }
  375 + trap("USR2") { Mongrel.log(:notice, "USR2 signal received."); stop(true) }
376 376
377   - log(:notice, "Signals ready. TERM => stop. USR2 => restart. INT => stop (no restart).")
  377 + Mongrel.log(:notice, "Signals ready. TERM => stop. USR2 => restart. INT => stop (no restart).")
378 378 else
379   - log(:notice, "Signals ready. INT => stop (no restart).")
  379 + Mongrel.log(:notice, "Signals ready. INT => stop (no restart).")
380 380 end
381 381 end
382 382
2  lib/mongrel/debug.rb
@@ -97,7 +97,7 @@ class Access < GemPlugin::Plugin "/handlers"
97 97 def process(request,response)
98 98 p = request.params
99 99 #STDERR.puts "#{p['REMOTE_ADDR']} - [#{Time.now.httpdate}] \"#{p['REQUEST_METHOD']} #{p["REQUEST_URI"]} HTTP/1.1\""
100   - log(:info, "#{p['REMOTE_ADDR']} \"#{p['REQUEST_METHOD']} #{p["REQUEST_URI"]} HTTP/1.1\"")
  100 + Mongrel.log(:info, "#{p['REMOTE_ADDR']} \"#{p['REQUEST_METHOD']} #{p["REQUEST_URI"]} HTTP/1.1\"")
101 101 end
102 102 end
103 103
17 lib/mongrel/logger.rb
@@ -3,10 +3,6 @@
3 3 # Merb: http://merbivore.com
4 4 module Mongrel
5 5
6   - #class << self
7   - # attr_accessor :logger
8   - #end
9   -
10 6 class Log
11 7 attr_accessor :logger
12 8 attr_accessor :log_level
@@ -20,12 +16,11 @@ def initialize(log, log_level = :debug)
20 16 @logger = initialize_io(log)
21 17 @log_level = Levels[:name][log_level]
22 18
23   - if !RUBY_PLATFORM.match(/java|mswin/) &&
24   - !(@log == STDOUT) &&
25   - @log.respond_to?(:write_nonblock)
26   -
  19 + if !RUBY_PLATFORM.match(/java|mswin/) && !(@log == STDOUT) &&
  20 + @log.respond_to?(:write_nonblock)
27 21 @aio = true
28 22 end
  23 + $MongrelLogger = self
29 24 end
30 25
31 26 # Writes a string to the logger. Writing of the string is skipped if the string's log level is
@@ -52,7 +47,7 @@ def initialize_io(log)
52 47 else
53 48 @log = open(log, (File::WRONLY | File::APPEND | File::CREAT))
54 49 @log.sync = true
55   - @log.write("#{Time.now.httpdate} Logfile created")
  50 + @log.write("#{Time.now.httpdate} Logfile created\n")
56 51 end
57 52 end
58 53
@@ -60,7 +55,9 @@ def initialize_io(log)
60 55
61 56 # Convenience wrapper for logging, allows us to use Mongrel.log
62 57 def self.log(level, string)
63   - logger.log(level,string)
  58 + # If no logger was defined, log to STDOUT.
  59 + $MongrelLogger ||= Mongrel::Log.new(STDOUT, :debug)
  60 + $MongrelLogger.log(level,string)
64 61 end
65 62
66 63 end
8 lib/mongrel/rails.rb
@@ -161,9 +161,9 @@ def reload!
161 161 raise "Rails was not configured. Read the docs for RailsConfigurator."
162 162 end
163 163
164   - log "Reloading Rails..."
  164 + Mongrel.log(:info, "Reloading Rails...")
165 165 @rails_handler.reload!
166   - log "Done reloading Rails."
  166 + Mongrel.log(:info, "Done reloading Rails.")
167 167
168 168 end
169 169
@@ -175,9 +175,9 @@ def setup_rails_signals(options={})
175 175
176 176 unless RUBY_PLATFORM =~ /djgpp|(cyg|ms|bcc)win|mingw/
177 177 # rails reload
178   - trap("HUP") { log "HUP signal received."; reload! }
  178 + trap("HUP") { Mongrel.log(:info, "HUP signal received."); reload! }
179 179
180   - log "Rails signals registered. HUP => reload (without restart). It might not work well."
  180 + Mongrel.log(:info, "Rails signals registered. HUP => reload (without restart). It might not work well.")
181 181 end
182 182 end
183 183 end
30 projects/mongrel_cluster/lib/mongrel_cluster/init.rb
@@ -80,23 +80,23 @@ def start
80 80 @ports.each do |port|
81 81 if @clean && pid_file_exists?(port) && !check_process(port)
82 82 pid_file = port_pid_file(port)
83   - log "missing process: removing #{pid_file}"
  83 + Mongrel.log(:info, "missing process: removing #{pid_file}")
84 84 chdir_cwd do
85 85 File.unlink(pid_file)
86 86 end
87 87 end
88 88
89 89 if pid_file_exists?(port) && check_process(port)
90   - log "already started port #{port}"
  90 + Mongrel.log(:info, "already started port #{port}")
91 91 next
92 92 end
93 93
94 94 exec_cmd = cmd + " -p #{port} -P #{port_pid_file(port)}"
95 95 exec_cmd += " -l #{port_log_file(port)}"
96   - log "starting port #{port}"
  96 + Mongrel.log(:info, "starting port #{port}")
97 97 log_verbose exec_cmd
98 98 output = `#{exec_cmd}`
99   - log(:error, output) unless $?.success?
  99 + Mongrel.log(:error, output) unless $?.success?
100 100 end
101 101 end
102 102
@@ -112,20 +112,20 @@ def stop
112 112 @ports.each do |port|
113 113 pid = check_process(port)
114 114 if @clean && pid && !pid_file_exists?(port)
115   - log "missing pid_file: killing mongrel_rails port #{port}, pid #{pid}"
  115 + Mongrel.log(:info, "missing pid_file: killing mongrel_rails port #{port}, pid #{pid}")
116 116 Process.kill("KILL", pid.to_i)
117 117 end
118 118
119 119 if !check_process(port)
120   - log "already stopped port #{port}"
  120 + Mongrel.log(:info, "already stopped port #{port}")
121 121 next
122 122 end
123 123
124 124 exec_cmd = cmd + " -P #{port_pid_file(port)}"
125   - log "stopping port #{port}"
  125 + Mongrel.log(:info, "stopping port #{port}")
126 126 log_verbose exec_cmd
127 127 output = `#{exec_cmd}`
128   - log(:error, output) unless $?.success?
  128 + Mongrel.log(:error, output) unless $?.success?
129 129
130 130 end
131 131 end
@@ -138,18 +138,18 @@ def status
138 138 @ports.each do |port|
139 139 pid = check_process(port)
140 140 unless pid_file_exists?(port)
141   - log(:error, "missing pid_file: #{port_pid_file(port)}")
  141 + Mongrel.log(:error, "missing pid_file: #{port_pid_file(port)}")
142 142 status = STATUS_ERROR
143 143 else
144   - log(:info, "found pid_file: #{port_pid_file(port)}")
  144 + Mongrel.log(:info, "found pid_file: #{port_pid_file(port)}")
145 145 end
146 146 if pid
147   - log(:info, "found mongrel_rails: port #{port}, pid #{pid}")
  147 + Mongrel.log(:info, "found mongrel_rails: port #{port}, pid #{pid}")
148 148 else
149   - log(:error, "missing mongrel_rails: port #{port}")
  149 + Mongrel.log(:error, "missing mongrel_rails: port #{port}")
150 150 status = STATUS_ERROR
151 151 end
152   - log(:info, "")
  152 + Mongrel.log(:info, "")
153 153 end
154 154
155 155 status
@@ -212,7 +212,7 @@ def find_pid(port)
212 212 end
213 213
214 214 def log_verbose(message)
215   - log(:info, message) if @verbose
  215 + Mongrel.log(:info, message) if @verbose
216 216 end
217 217
218 218 end
@@ -329,7 +329,7 @@ def run
329 329 @options["group"] = @group if @group
330 330 @options["prefix"] = @prefix if @prefix
331 331
332   - log "Writing configuration file to #{@config_file}."
  332 + Mongrel.log(:info, "Writing configuration file to #{@config_file}.")
333 333 File.open(@config_file,"w") {|f| f.write(@options.to_yaml)}
334 334 end
335 335 end
2  site/src/docs/howto.page
@@ -398,7 +398,7 @@ You can use the -S configure script to add your own handlers
398 398 with code like this:
399 399
400 400 <pre><code>
401   - trap("USR1") { log "I'm doing stuff." }
  401 + trap("USR1") { Mongrel.log(:info, "I'm doing stuff.") }
402 402 </code></pre>
403 403
404 404

0 comments on commit 79948cb

Please sign in to comment.
Something went wrong with that request. Please try again.