I need to put together a very simple web site and would like to use rails, but I need a simple indexing/search engine to go with it (like risearch and php, or lucerne and java). Any suggestions? Thanks
I wonder if it would be possible to use SWIG to create Ruby bindings for lucene similiar to what was done for PyLucene? http://pylucene.osafoundation.org/ On Sat, 12 Feb 2005 01:13:06 -0500, Heitzso <heitzso-Bdlq13kUjeyLZ21kGMrzwg@public.gmane.org> wrote:> I need to put together a very simple web site and would > like to use rails, but I need a simple indexing/search engine > to go with it (like risearch and php, or lucerne and java). > Any suggestions? > > Thanks > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Hello all, I have a Rails application that uses a mySQL database. It runs on the intranet here, and frequently doesn''t get accessed for a span of 8 hours or more (especially since I''m its sole developer and its not even done yet). I often run into the following problem: After a period of inactivity, I try to access any page that references an active record model, and it errors out. The error message is "Invalid argument: #{any SQL statement you want here}". I asked about this on IRC, and thanks to some very helpful folks, the problem has been narrowed down to the SQL connection timing out after 8 hours and disconnecting, and Rails not re-connecting. This coincides with the mySQL logs - when the error is thrown above, there is no activity in the database logs. Is there a way I can tell Rails to reconnect to the database if the connection is dropped? This seems like it can''t be only a problem I''ve run in to... Everyone isn''t constantly restarting apache when developing a site on their own box are they? ;) Thanks for any help you guys can provide! -Brian Terlson
On Sat, 12 Feb 2005 00:40:46 -0600, Steve Longdo <steve.longdo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I wonder if it would be possible to use SWIG to create Ruby bindings > for lucene similiar to what was done for PyLucene? >I integrated Lucene with a Frontier application using a thin XML-RPC wrapper. Not as neat perhaps, but very simple to do. M -- Matt Mower :: http://matt.blogs.it/
* Brian Terlson <terl0004-OJFnDUYgAso@public.gmane.org> [0259 07:59]:> Is there a way I can tell Rails to reconnect to the database if the > connection is dropped? This seems like it can''t be only a problem I''ve > run in to... Everyone isn''t constantly restarting apache when > developing a site on their own box are they? ;)I think it''d be worth trying to stop mysqld from dropping the connection. -- ''Aww, you know what always cheers me up? Laughing at other people''s misfortunes.'' -- Bender Rasputin :: Jack of All Trades - Master of Nuns
Dick Davies wrote:>* Brian Terlson <terl0004-OJFnDUYgAso@public.gmane.org> [0259 07:59]: > > >>Is there a way I can tell Rails to reconnect to the database if the >>connection is dropped? This seems like it can''t be only a problem I''ve >>run in to... Everyone isn''t constantly restarting apache when >>developing a site on their own box are they? ;) >> >> > >I think it''d be worth trying to stop mysqld from dropping the connection. > > >I considered this also, but it seemed to be the general consensus on the IRC channel that doing so would be a bad idea. I forgot what the reasons were exactly. Plus, I looked through all the configs I could find and couldn''t see any way to configure the connection drop time. For now what I''m going to do is put a stupid VB app on the server to request the page every 4 hours or so to keep the connection fresh. It seems uber stupid, and it is, but I haven''t found any other alternative :''(
On Sat, 12 Feb 2005 01:59:19 -0600, Brian Terlson <terl0004-OJFnDUYgAso@public.gmane.org> wrote:> I have a Rails application that uses a mySQL database. It runs on the > intranet here, and frequently doesn''t get accessed for a span of 8 hours > or more (especially since I''m its sole developer and its not even done > yet). I often run into the following problem: After a period of > inactivity, I try to access any page that references an active record > model, and it errors out. The error message is "Invalid argument: #{any > SQL statement you want here}".I have the same problem, but with a slightly different error message (StatementInvalid/Broken pipe). I chatted briefly to David about it on the IRC channel yesterday, and he was of the opinion that the error should be caught (by Rails) so that the connection could be re-established if it has been lost. I agree that this is the best strategy. However, he also wanted a patch :) I''d be happy to contribute, but I''m very new to both Ruby and Rails so I''m feeling lost. As a first (and probably lame) attempt I tried to make the method "connected?" in abstract_adapter.rb always return false to see if I was on the right track, but that didn''t make any difference, so I guess I was barking up the wrong tree. Any ideas where the error needs to be caught? How does one check that a pipe isn''t broken before using it? Should it be a generic fix or should it be specific to the MySQL adapter? -- Regards, Stian Grytøyr
On Mon, 14 Feb 2005 11:07:26 +0100, Stian Grytøyr <sgrytoyr-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Sat, 12 Feb 2005 01:59:19 -0600, Brian Terlson <terl0004-OJFnDUYgAso@public.gmane.org> wrote: > > > I have a Rails application that uses a mySQL database. It runs on the > > intranet here, and frequently doesn''t get accessed for a span of 8 hours > > or more (especially since I''m its sole developer and its not even done > > yet). I often run into the following problem: After a period of > > inactivity, I try to access any page that references an active record > > model, and it errors out. The error message is "Invalid argument: #{any > > SQL statement you want here}". > > I have the same problem, but with a slightly different error message > (StatementInvalid/Broken pipe). I chatted briefly to David about it on > the IRC channel yesterday, and he was of the opinion that the error > should be caught (by Rails) so that the connection could be re-established > if it has been lost. I agree that this is the best strategy. However, he also > wanted a patch :) > > I''d be happy to contribute, but I''m very new to both Ruby and Rails so > I''m feeling lost. As a first (and probably lame) attempt I tried to make > the method "connected?" in abstract_adapter.rb always return false to > see if I was on the right track, but that didn''t make any difference, so I > guess I was barking up the wrong tree. > > Any ideas where the error needs to be caught? How does one check that > a pipe isn''t broken before using it? Should it be a generic fix or should it > be specific to the MySQL adapter?This shouldn''t be taken as gospel as it''s been about 4 years in rails time (1 month) since I last sent a patch through. However, there''s a method execute in the mysql_adapter: def execute(sql, name = nil) http://dev.rubyonrails.org/file/trunk/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb This method could catch the exception that gets thrown, try to reconnect and resubmit the request. It''s not perfect but it''s a starting point, just remember to ensure you don''t get into an infinite loop. As for supporting this problem in other adapters, forget about it until the problem appears with another adapter. Lets not write code that solves problems we don''t have, that''s how we ended up with EJBs and WS-*. </dig>> -- > Regards, > Stian Grytøyr > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Cheers Koz
On Tue, 15 Feb 2005 15:18:48 +1300, Michael Koziarski <koziarski-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> However, there''s a method execute in the mysql_adapter: > > def execute(sql, name = nil)[...]> This method could catch the exception that gets thrown, try to > reconnect and resubmit the request. It''s not perfect but it''s a > starting point, just remember to ensure you don''t get into an infinite > loop.Yes, that might be a good place to start. However, not all database calls go through execute, a good example being "columns". But that shouldn''t be too difficult to fix, I think. What I''m more unsure of is how one would actually re-establish the connection from within the rescue block. At the moment I''m doing something like this: log(sql, name, @connection) { |connection| begin result = connection.query(sql) rescue ActiveRecord::Base.establish_connection # retry end } In a way, this works. You get the error once, but on subsequent reloads things work just fine. But if I add the retry statement, I get the good ol'' infinite loop, presumably because @connection still isn''t right for _this_ instance. I''ve tried several variations of the above, but no luck. It would be great if someone with a stronger command of Ruby could shed some light on the matter. -- Regards, Stian Grytøyr
> What I''m more unsure of is how one would actually re-establish the > connection from within the rescue block. At the moment I''m doing > something like this: > > log(sql, name, @connection) { |connection| > begin > result = connection.query(sql) > rescue > ActiveRecord::Base.establish_connection > # retry > end > }Perhaps you could put the begin and rescue outside of the log block: eg begin log(sql, name, @connection) do |connection| result = connection.query(sql) end rescue ActiveRecord::Base.establish_connection retry end Hadley
On Tue, 15 Feb 2005 08:08:53 -0600, hadley wickham <h.wickham-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Perhaps you could put the begin and rescue outside of the log block: eg > > begin > log(sql, name, @connection) do |connection| > result = connection.query(sql) > end > rescue > ActiveRecord::Base.establish_connection > retry > endI get the same behaviour with this approach - the browser hangs until the timeout and dispatch.fcgi runs wild. Next reload is ok. -- Regards, Stian Grytøyr