Running rails server as daemon

114 views
Skip to first unread message

Javi

unread,
Feb 18, 2011, 12:11:06 PM2/18/11
to xapian_db
Hi!

I discovered this gem about a week ago, and it looks like the perfect
replacement for Xapit using Ruby 1.9.

I'm having a bit of a problem, however. When I start the rails server
with the "-d" option, my searches don't work:

DatabaseOpeningError: Couldn't open db/xapian_db/development/record.DB
to read: No such file or directory
xapian_db (0.5.3) lib/xapian_db/database.rb:156:in `reopen'
(...)
xapian_db (0.5.3) lib/xapian_db/adapters/base_adapter.rb:39:in `block
(2 levels) in add_class_helper_methods_to'
app/controllers/posts_controller.rb:66:in `search'

I've tried using WEBrick, mongrel and thin, in both development and
production mode. The same error happens with all those configurations.

Worse yet, whenever I try to update a model that's indexed, it crashes
as well:

DatabaseOpeningError: No chert database found at path `db/xapian_db/
development'
xapian_db (0.5.3) lib/xapian_db/database.rb:165:in `initialize'
(...)
xapian_db (0.5.3) lib/xapian_db/adapters/active_record_adapter.rb:
44:in `block (2 levels) in add_class_helper_methods_to'

Everything works fine when running it witouth the daemon option.

My xapian database configuration is the same for all the environments:

adapter: active_record
language: es
writer: direct

I've found a workaround by specifying the database path as absolute:

database: /home/javier/my_app/db/xapian_db/development

Of course this is not the most convenient. Are you aware of any other
options?

Thanks!

Gernot

unread,
Feb 19, 2011, 2:18:55 AM2/19/11
to xapian_db
Hi Javi!

Thanks for your feedback! The fix is ready and will be included in the
next release.

Please note that running a production configuration with the direct
writer is dangerous unless you are absolutely sure that you have only
one instance of your app running (see the README for details). I would
recommend to always use the beanstalk writer in production
environments since the beanstalk writer is asynchronous and makes your
app more responsive.

Since you know xapit: Do you miss any configuration options for the
xapian engine? I tried to set sensible defaults and keep the
configuration simple, but if you miss anything, please let me know.

best regards
Gernot

Javi

unread,
Feb 20, 2011, 12:40:21 PM2/20/11
to xapian_db
Hi, Gernot! Thanks for your answer.

> Please note that running a production configuration with the direct
> writer is dangerous unless you are absolutely sure that you have only
> one instance of your app running (see the README for details). I would
> recommend to always use the beanstalk writer in production

I know! At the moment beanstalk isn't installed in my hosting, and the
site is in a pre-production environment, so in the meantime I'm using
the direct writer.

> Since you know xapit: Do you miss any configuration options for the
> xapian engine?

I haven't used the configuration options heavily, but I'll make some
general comments.

Using xapit, I could write something like:

@posts = Post.search "xapian", :per_page => 15, :page => 1
@posts.each { |post| link_to post.title, post }

Same code with xapian_db:

@results = Post.search "xapian", :per_page => 15, :page => 1
@results.paginate.each { |result| link_to result.title,
result.indexed_object }

I find xapit's way more elegant to do such a common task.

In the README you recommend configuring the blueprints in a separate
config file. I'm not doing it that way. The reason is, I'm using Spork
as a test server. If I include the blueprints for my Post model in the
config file, then that model is cached when Spork is started. The
simplest solution I found was moving the blueprints to the Post model.

Right now I don't remember if I used xapit or acts_as_xapian, but
there was an application where I used a xapian gem to find similar or
related posts to the one I was showing.

And finally, I prefer xapit's way of returning a non-existent
spelling_suggestion as nil instead of as an empty string, so it's
easier to use as a condition. But that's a matter of taste, I guess.

I've just started using it, so if in the future I've got more
comments, I'll let you know.

Regards.

Gernot

unread,
Feb 21, 2011, 2:54:59 AM2/21/11
to xapian_db
Hi Javi

Very reasonable points, thanks for your feedback! I'll consider them
for the next version.

Cheers,
Gernot
Reply all
Reply to author
Forward
0 new messages