Skip to content
This repository

running solr on jruby: "fork is not available on this platform" #163

Closed
krisleech opened this Issue January 12, 2012 · 14 comments

5 participants

Kris Leech Nick Zadrozny Andy Lindeman Martin Jarvis Geoffrey Catto
Kris Leech

rake sunspot:solr:start gives fork is not available on this platform when using JRuby. Is there another method other than fork that would be used to start Solr in the background.

My problem is I can't automatically start Solr before my tests run I have manually start Solr in the foreground using rake sunspot:solr:run.

Rails 3.1.0
JRuby 1.6.5
Sunspot 1.3.0

Kris Leech

The answer might be to use spawn provided by the spoon gem: http://rubydoc.info/gems/spoon/0.0.1/frames

I'll have a go myself. Of course this would add an extra dependency but only for JRuby.

Andy Lindeman
Collaborator

How's this going? I like the idea of being able to run on JRuby.

Martin Jarvis

rake sunspot:solr:run on Windows with JRuby

I don't know if this is a Windows issue or a JRuby issue, but the exec at line 104 in sunspot/solr/server.rb is causing a problem.
FileUtils.cd(File.dirname(solr_jar)) do
exec(Escape.shell_command(command))
end
The java command line reports an error that it can not find the start.jar. I added some debug to my copy and discovered that the exec'ed java command is not actually being executed in the correct directory. If I change the exec(...) to a system(...) it works fine. I think system would be a safer style of command execution on all platforms. This rake task is only used during development and test so optimisation is not so necessary.

Nick Zadrozny
Owner
nz commented January 28, 2012

IMO, we should drop responsibility for backgrounding. Leave that up to foreman or the like.

Andy Lindeman
Collaborator

Cool with me. Just drop sunspot:solr:run and print out a useful message about it?

Martin Jarvis

Speaking as someone who is using Sunspot, I'd rather not have install foreman. I like using the sunspot:solr:run task to fire up solr. My patched version using "system" works fine and should be consistent across ruby platforms. My sugestion is just that you just change exec(...) to system(...).

Nick Zadrozny
Owner
nz commented January 28, 2012

I might have conflated two issues with my response — sunspot:solr:run should always work to run Solr in the foreground. I'm on the fence about sunspot:solr:start taking on the responsibility of backgrounding. Sunspot is not a process manager ;)

Also, running a multi-core Solr on a single port (another WIP for 2.0) could help alleviate the inconvenience mentioned earlier by @krisleech.

Andy Lindeman
Collaborator

I meant to say sunspot:solr:start above, doh!

Martin Jarvis

sunspot:solr:start works perfectly on my mac (my main development environment). Is there any reason why you'd want to remove something that works fine? Is it causing you a maintenance headache?

Nick Zadrozny
Owner
nz commented January 28, 2012

@freakent sunspot:solr:start it breaks on Windows and JRuby IIRC. So perhaps the better option is to keep our implementation naive (print a notice on exception?) unless a suitably trivial fix can be contributed for those platforms.

Martin Jarvis

As far as I understood, on Jruby/Windows s:s:start gives a message saying it is not supported on that platform and you should use s:s:run. That's fair enough as long as s:s:run works, and my suggestion is to swap the exec() for a system(). Seems like a minor fix to me.

Geoffrey Catto

I was having the same issue as freakent with JRuby on Windows. His solution of replacing the call to exec(...) on line 104 of server.rb with a call to system(...) worked for me as well.

Kris Leech

AFAIK it is fork [1] in start which is not supported by JRuby on any platform. The exec (or system) calls in run are fine, at least on Unix.

The need to swap exec for system on Windows should be opened as a separate issue IMHO.

[1] https://github.com/sunspot/sunspot/blob/master/sunspot_solr/lib/sunspot/solr/server.rb#L68

Nick Zadrozny
Owner

I'm going to close this one, since it's rather old. I am still of the opinion that we should support :run everywhere, but consider the backgrounding behavior of :start to be optional given platform differences. Managing background processes should not be within Sunspot's scope of concerns, unless someone can show me a fairly minimal pull request that adds support on all platforms.

Nick Zadrozny nz closed this September 08, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.