Fix upgrade to Rails 1.2.3.

Fix log-rotation (the previous attempt didn't quite work as advertised).
This commit is contained in:
Jacques Distler 2007-03-21 15:37:29 -05:00
parent 7adac51d6d
commit 9b9d134ad9
5 changed files with 46 additions and 11 deletions

View file

@ -2,7 +2,6 @@ class Wiki
cattr_accessor :storage_path, :logger cattr_accessor :storage_path, :logger
self.storage_path = "#{RAILS_ROOT}/storage/" self.storage_path = "#{RAILS_ROOT}/storage/"
self.logger = INSTIKI_LOGGER
def authenticate(password) def authenticate(password)
password == (system.password || 'instiki') password == (system.password || 'instiki')
@ -38,14 +37,14 @@ class Wiki
end end
def read_page(web_address, page_name) def read_page(web_address, page_name)
self.class.logger.debug "Reading page '#{page_name}' from web '#{web_address}'" ApplicationController.logger.debug "Reading page '#{page_name}' from web '#{web_address}'"
web = Web.find_by_address(web_address) web = Web.find_by_address(web_address)
if web.nil? if web.nil?
self.class.logger.debug "Web '#{web_address}' not found" ApplicationController.logger.debug "Web '#{web_address}' not found"
return nil return nil
else else
page = web.pages.find(:first, :conditions => ['name = ?', page_name]) page = web.pages.find(:first, :conditions => ['name = ?', page_name])
self.class.logger.debug "Page '#{page_name}' #{page.nil? ? 'not' : ''} found" ApplicationController.logger.debug "Page '#{page_name}' #{page.nil? ? 'not' : ''} found"
return page return page
end end
end end

View file

@ -6,18 +6,15 @@ config.cache_classes = true
# config.logger = SyslogLogger.new # config.logger = SyslogLogger.new
#### ####
# This one rotates the log file, keeping 25 files, of 1MB each. # This rotates the log file, keeping 25 files, of 1MB each.
INSTIKI_LOGGER = Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}.log", 25, 1024000) config.action_controller.logger = Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}.log", 25, 1024000)
# Unfortunately, the above does not work well under Mongrel, as the default Ruby logger class # Unfortunately, the above does not work well under Mongrel, as the default Ruby logger class
# does no locking and you will have several processes running, each wanting to write to (and # does no locking and you will have several processes running, each wanting to write to (and
# rotate) the log file. One solution is to have each mongrel instance writes to a different log file: # rotate) the log file. One solution is to have each mongrel instance writes to a different log file:
# http://blog.caboo.se/articles/2006/11/14/configure-mongrel-rails-logger-per-port for a solution. # http://blog.caboo.se/articles/2006/11/14/configure-mongrel-rails-logger-per-port for a solution.
# Another is to use the default logging behaviour: # Another is to use the default logging behaviour (comment out the above line)
#INSTIKI_LOGGER = RAILS_DEFAULT_LOGGER
# and use an external program (e.g. logrotate) to rotate the logs. # and use an external program (e.g. logrotate) to rotate the logs.
#### ####

View file

@ -0,0 +1,30 @@
# CGI::Session#create_new_id requires 'digest/md5' on every call. This makes
# sense when spawning processes per request, but is unnecessarily expensive
# when serving requests from a long-lived process.
#
# http://railsexpress.de/blog/articles/2005/11/22/speeding-up-the-creation-of-new-sessions
require 'cgi/session'
require 'digest/md5'
class CGI
class Session #:nodoc:
private
# Create a new session id.
#
# The session id is an MD5 hash based upon the time,
# a random number, and a constant string. This routine
# is used internally for automatically generated
# session ids.
def create_new_id
md5 = Digest::MD5::new
now = Time::now
md5.update(now.to_s)
md5.update(String(now.usec))
md5.update(String(rand(0)))
md5.update(String($$))
md5.update('foobar')
@new_session = true
md5.hexdigest
end
end
end

View file

@ -0,0 +1,3 @@
class MixedCaseMonkey < ActiveRecord::Base
set_primary_key 'monkeyID'
end

View file

@ -0,0 +1,6 @@
first:
monkeyID: 1
fleaCount: 42
second:
monkeyID: 2
fleaCount: 43