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

@ -1,8 +1,7 @@
class Wiki
class Wiki
cattr_accessor :storage_path, :logger
self.storage_path = "#{RAILS_ROOT}/storage/"
self.logger = INSTIKI_LOGGER
def authenticate(password)
password == (system.password || 'instiki')
@ -38,14 +37,14 @@ class Wiki
end
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)
if web.nil?
self.class.logger.debug "Web '#{web_address}' not found"
ApplicationController.logger.debug "Web '#{web_address}' not found"
return nil
else
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
end
end

View file

@ -6,18 +6,15 @@ config.cache_classes = true
# 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
# 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:
# 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:
#INSTIKI_LOGGER = RAILS_DEFAULT_LOGGER
# Another is to use the default logging behaviour (comment out the above line)
# 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