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

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

Comments

Projects
None yet
5 participants
@krisleech

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

@krisleech

This comment has been minimized.

Show comment
Hide comment
@krisleech

krisleech Jan 12, 2012

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.

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.

@alindeman

This comment has been minimized.

Show comment
Hide comment
@alindeman

alindeman Jan 28, 2012

Member

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

Member

alindeman commented Jan 28, 2012

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

@freakent

This comment has been minimized.

Show comment
Hide comment
@freakent

freakent Jan 28, 2012

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.

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.

@nz

This comment has been minimized.

Show comment
Hide comment
@nz

nz Jan 28, 2012

Member

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

Member

nz commented Jan 28, 2012

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

@alindeman

This comment has been minimized.

Show comment
Hide comment
@alindeman

alindeman Jan 28, 2012

Member

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

Member

alindeman commented Jan 28, 2012

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

@freakent

This comment has been minimized.

Show comment
Hide comment
@freakent

freakent Jan 28, 2012

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(...).

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(...).

@nz

This comment has been minimized.

Show comment
Hide comment
@nz

nz Jan 28, 2012

Member

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.

Member

nz commented Jan 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.

@alindeman

This comment has been minimized.

Show comment
Hide comment
@alindeman

alindeman Jan 28, 2012

Member

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

Member

alindeman commented Jan 28, 2012

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

@freakent

This comment has been minimized.

Show comment
Hide comment
@freakent

freakent Jan 28, 2012

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?

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?

@nz

This comment has been minimized.

Show comment
Hide comment
@nz

nz Jan 28, 2012

Member

@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.

Member

nz commented Jan 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.

@freakent

This comment has been minimized.

Show comment
Hide comment
@freakent

freakent Jan 28, 2012

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.

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.

@gcatto

This comment has been minimized.

Show comment
Hide comment
@gcatto

gcatto Mar 12, 2012

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.

gcatto commented Mar 12, 2012

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.

@krisleech

This comment has been minimized.

Show comment
Hide comment
@krisleech

krisleech Jun 10, 2012

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

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

@nz

This comment has been minimized.

Show comment
Hide comment
@nz

nz Sep 8, 2013

Member

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.

Member

nz commented Sep 8, 2013

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.

@nz nz closed this Sep 8, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment