At a slight tangent, isolating application sessions won't fully solve
this problem; you can change the name of a Model object and see this
'white screen of death' within the same application. Something needs
to be wrapped around the session loading to let Rails gracefully
handle loading a malignant session and at least give the user *some*
feedback (logs, 500 status, anything really).

That said, I think creating the RAILS_ROOT/tmp directory on-demand is
a good idea - as Jamis points out, there are already files (like
fastcgi sockets) which are floating around and need an appropriate
home - a tmp directory seems to make sense here. It wouldn't be hard
to provide a rake task to clean it up/remove it either:

  desc 'Clear all sessions and temporary files for this application'
  task :clear_tmp => :environment do
    # presuming RAILS_TMP is either defined by the user, or set by default:
    # RAILS_TMP = File.join(RAILS_ROOT, 'tmp') unless
Object.const_defined?(:RAILS_TMP)
    FileUtils.rm_r(RAILS_TMP)
  end

  desc 'Clean application'
  task :clean => [:clear_logs, :clear_tmp]


... or whatever.

- James

On 1/26/06, Duane Johnson <[EMAIL PROTECTED]> wrote:
> Jamis Buck and I had a few ideas tonight that would each take care of the
> CgiRequest bug where switching between Rails apps that have different
> classes (models) stored in the session causes the whole app to crash without
> a trace.  Of course, the problem is only present when using the FileStore to
> store session data, since if the sessions are being stored in the DB, there
> shouldn't be any conflict between apps.
>
> Option #1: Add a "tmp" folder to the Rails app directory structure and store
> session files in "#{RAILS_ROOT}/tmp".  If each app has its own tmp folder,
> we could instruct it do something like this inside of the Rails initializer:
>
> ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:tmpdir]
> = File.join(RAILS_ROOT, 'tmp')
>
> Option #2: Create some kind of UUID or unique ID per app, and store rubysess
> files in "/tmp/#{app_specific_id}/rubysess.*"  This would
> require modifying railties to create a UUID when the rails app is first
> generated.
>
> Option #3 (?): Use the UUID in the rubysess filename, e.g.
> rubysess.#{app_specific_id}.#{random_number}.  I don't know
> if this one is possible, since I don't know of a way to change the name of
> the files that CGI::Session FileStore.
>
>
> I've heard that some core members aren't too excited about adding a tmp/
> folder to RAILS_ROOT, and I can understand why; however, adding the tmp/
> folder (option #1) may be the best solution for a number of reasons:
>
> a) It guarantees that there will be no conflict between rails apps
> b) Apps can benefit from the change immediately (no need to generate a UUID
> with railties)
> c) We'll finally have a place to put those pesky fastcgi socket files
> d) Other plugins may benefit from a tmp/ folder, e.g. file_column?
>
>
> Cast your ballots.
>
>
> Duane Johnson
> (canadaduane)
> http://blog.inquirylabs.com/
>
>
> _______________________________________________
> Rails-core mailing list
> Rails-core@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails-core
>
>
>
_______________________________________________
Rails-core mailing list
Rails-core@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-core

Reply via email to