ruby lsapi removes RAILS_ROOT value from ENV

Discussion in 'Bug Reports' started by Grzegorz Derebecki, May 17, 2010.

  1. Grzegorz Derebecki

    Grzegorz Derebecki New Member

    after include lsapi it removes RAILS_ROOT varible from ENV why?
    also why include lsapi chdir to rails_root? rails_runner do this!
    (i think it is bad design that include makes something like that)


    Code:
    require "rubygems"
    
    ENV["RAILS_ROOT"] = "./"
    
    
    puts "BEFORE: #{ENV["RAILS_ROOT"]}"
    require "lsapi"
    
    $stdout = IO::STDOUT
    
    puts "AFTER: #{ENV["RAILS_ROOT"]}"
    
    
    
    maby this is problem:

    /* Do not need those environments after initialization */
    remove_env = rb_str_new( "RAILS_ROOT", 10 );
    rb_funcall( env_copy, rb_intern( "delete" ), 1, remove_env );



    Also why include lsapi change default stdout? Why it don't to that after calling some start metod like LSAPI.accept or something similar.
    Last edited: May 17, 2010
  2. mistwang

    mistwang LiteSpeed Staff

    Both are done for efficiency, it requires to copy the environment variables for each request, so we want to keep number of environment variables as small as possible.
    For the default stdout, maybe it is not necessary, we receive some requests to redirect it. If we can do it once during initialization, will avoid doing it for each request.

    Both are minor details, so there should not be a problem do it one way or the other.

    We also thinking to redirect rails exceptions from our stderr.log to the application log, but have no clue how to do it.
  3. Grzegorz Derebecki

    Grzegorz Derebecki New Member

    i think RAILS_ROOT shouldn't be removed. Also RAILS_ROOT isn't set once when ruby starts?

    By the way i wrote Rails3 runner: http://github.com/madmax/lsws-rails3-runner

Share This Page