Hi, Whenever I restart mongrel on my production server, the first request in my browser always fails, I get this error: Processing Base#index (for 83.xx.xx.xx at 2006-09-03 16:08:47) [GET] Session ID: f1918346d193e19a70c3230286e5ce1a Parameters: {} TypeError (superclass mismatch for class Stats): /app/models/stats.rb:1 stats.rb:1 just contains a normal A/R line: class Stats < ActiveRecord::Base Strange thing is that when I reload the page in my browser things work and every subsequent request works. Until I restart mongrel, the same happens again. I''m using postgresql so I''m wondering if something''s going wrong on the initial connect. Any ideas?? Jeroen
On Sun, 2006-09-03 at 16:12 +0200, Jeroen Houben wrote:> Hi, > > Whenever I restart mongrel on my production server, the first request in > my browser always fails, I get this error: > > Processing Base#index (for 83.xx.xx.xx at 2006-09-03 16:08:47) [GET] > Session ID: f1918346d193e19a70c3230286e5ce1a > Parameters: {} > > > TypeError (superclass mismatch for class Stats): > /app/models/stats.rb:1Ah, there''s a Stats class already in Mongrel but it''s not in the mongrel module. I''ll move that over and see if it breaks anyone. -- Zed A. Shaw http://www.zedshaw.com/ http://mongrel.rubyforge.org/ http://www.lingr.com/room/3yXhqKbfPy8 -- Come get help.
Zed Shaw wrote:> On Sun, 2006-09-03 at 16:12 +0200, Jeroen Houben wrote: >> Hi, >> >> Whenever I restart mongrel on my production server, the first request in >> my browser always fails, I get this error: >> >> Processing Base#index (for 83.xx.xx.xx at 2006-09-03 16:08:47) [GET] >> Session ID: f1918346d193e19a70c3230286e5ce1a >> Parameters: {} >> >> >> TypeError (superclass mismatch for class Stats): >> /app/models/stats.rb:1 > > Ah, there''s a Stats class already in Mongrel but it''s not in the mongrel > module. I''ll move that over and see if it breaks anyone. > >Aha. Could this also be the cause of my other problem where my custom ENV[''site''] value does not get picked up by environment.rb? http://www.ruby-forum.com/topic/79765#133114 ENV[''site''] *is* available in my views, controllers etc but doing: RAILS_DEFAULT_LOGGER.warn("ENV: #{ENV.inspect}") in environment.rb shows no sign of ENV[''site''] Jeroen
On Sun, 2006-09-03 at 16:34 +0200, Jeroen Houben wrote:> Zed Shaw wrote: > > On Sun, 2006-09-03 at 16:12 +0200, Jeroen Houben wrote:> Aha. Could this also be the cause of my other problem where my custom > ENV[''site''] value does not get picked up by environment.rb? > http://www.ruby-forum.com/topic/79765#133114 > > ENV[''site''] *is* available in my views, controllers etc but doing: > > RAILS_DEFAULT_LOGGER.warn("ENV: #{ENV.inspect}") > > in environment.rb shows no sign of ENV[''site'']Nope, the only reference to ENV in mongrel is in rails.rb where I set it for production. Otherwise, that''s a Ruby constant so you''d see big complaints if I messed with that (or anyone did). But, why are you using ENV? You could just use any constant you want in environment.rb. Try making a SITE_CONFIG = {''site'' => ''stuff.com''} and see if that works instead. In truth, getting site config values from ENV is kind of a no-no since you can''t trust ENV. It''s the reason a lot of programs clear ENV before starting other programs. -- Zed A. Shaw http://www.zedshaw.com/ http://mongrel.rubyforge.org/ http://www.lingr.com/room/3yXhqKbfPy8 -- Come get help.
Zed Shaw wrote:> But, why are you using ENV? You could just use any constant you want in > environment.rb. Try making a SITE_CONFIG = {''site'' => ''stuff.com''} and > see if that works instead.The reason I''m using it is because I''m running multiple sites from one rails app. I''m trying to pass some sort of variable to each mongrel upon startup to indicate which subdomain (and thus which client) each mongrel belongs to. I''m sure there is a better and DRYer way to so this, but I haven''t found it yet. Anyway, then in environment.rb I do something like this: # Set the SITE constant. Defaults to ''demo'' SITE = ENV[''site ? ENV[''site''] : ''demo ## initialize site specific information globals_file = File.join(File.dirname(__FILE__), "../sites/#{SITE}/config/Globals.rb") if File.exist?(globals_file) require globals_file else ... The SITE constant is also used in database.yml> In truth, getting site config values from ENV is kind of a no-no since > you can''t trust ENV. It''s the reason a lot of programs clear ENV before > starting other programs. >Yeah I figured it wasn''t the best way, but it worked for my lighty+fastcgi setup so I never really thought about it anymore. Thanks for replying so quickly btw! Jeroen
On Sun, 2006-09-03 at 17:45 +0200, Jeroen Houben wrote:> Zed Shaw wrote: > > But, why are you using ENV? You could just use any constant you want in > > environment.rb. Try making a SITE_CONFIG = {''site'' => ''stuff.com''} and > > see if that works instead. > > The reason I''m using it is because I''m running multiple sites from one > rails app. I''m trying to pass some sort of variable to each mongrel upon > startup to indicate which subdomain (and thus which client) each > mongrel belongs to. I''m sure there is a better and DRYer way to so this, > but I haven''t found it yet.Ok, why not an environment for each site? Just like production.rb or development.rb, but demo.rb, mysite.rb. Then, you just pass in -e demo.rb. People do this quite frequently, only catch is to make sure that you haven''t relied on the environment setting for other stuff, but even that you could change to "production" manually inside the demo.rb. -- Zed A. Shaw http://www.zedshaw.com/ http://mongrel.rubyforge.org/ http://www.lingr.com/room/3yXhqKbfPy8 -- Come get help.
Zed Shaw wrote:> On Sun, 2006-09-03 at 17:45 +0200, Jeroen Houben wrote: >> Zed Shaw wrote: >>> But, why are you using ENV? You could just use any constant you want in >>> environment.rb. Try making a SITE_CONFIG = {''site'' => ''stuff.com''} and >>> see if that works instead. >> The reason I''m using it is because I''m running multiple sites from one >> rails app. I''m trying to pass some sort of variable to each mongrel upon >> startup to indicate which subdomain (and thus which client) each >> mongrel belongs to. I''m sure there is a better and DRYer way to so this, >> but I haven''t found it yet. > > Ok, why not an environment for each site? Just like production.rb or > development.rb, but demo.rb, mysite.rb. Then, you just pass in -e > demo.rb. > > People do this quite frequently, only catch is to make sure that you > haven''t relied on the environment setting for other stuff, but even that > you could change to "production" manually inside the demo.rb. > >Interesting. I can''t help to feel this is a bit hackish too. But if it works it works I suppose.. So I''m guessing you need individual mongrel_cluster.yml files for each site and then fire up the mongrel_cluster with -C switch. I''ll give that a go later tonight. Thanks! Jeroen
Zed Shaw wrote:> On Sun, 2006-09-03 at 16:12 +0200, Jeroen Houben wrote: >> Hi, >> >> Whenever I restart mongrel on my production server, the first request in >> my browser always fails, I get this error: >> >> Processing Base#index (for 83.xx.xx.xx at 2006-09-03 16:08:47) [GET] >> Session ID: f1918346d193e19a70c3230286e5ce1a >> Parameters: {} >> >> >> TypeError (superclass mismatch for class Stats): >> /app/models/stats.rb:1 > > Ah, there''s a Stats class already in Mongrel but it''s not in the mongrel > module. I''ll move that over and see if it breaks anyone. > >Zed, could you maybe tell me if this change is going to be in the next release? I''ll be happy to report back my experience after installing it of course. Jeroen
On Mon, 2006-09-04 at 19:07 +0200, Jeroen Houben wrote:> Zed Shaw wrote: > > > > Ah, there''s a Stats class already in Mongrel but it''s not in the mongrel > > module. I''ll move that over and see if it breaks anyone. > > > > > > Zed, could you maybe tell me if this change is going to be in the next > release? > > I''ll be happy to report back my experience after installing it of course.Yep, it''s on my list. If you''re in a hurry though you should change it to Statistics now. -- Zed A. Shaw http://www.zedshaw.com/ http://mongrel.rubyforge.org/ http://www.lingr.com/room/3yXhqKbfPy8 -- Come get help.