i've installed per the readme file, but i've noticed something strange. I run java -jar start.jar using SSH and it loads and solr runs fine. I go to the solr admin page and am able to connect to solr fine.

BUT, then i close the window of the SSH and close the session, solr becomes unavailable! How do i keep it running all the time?

thanks.

Comments

janusman’s picture

You need to run Solr in the background properly. I achieve that with this command:

nohup java -jar start.jar >logfile 2>&1 &;

This outputs a process number to the terminal; you should store it for future reference so you can later kill that process if you need to =)

Please tell me if this worked for you.

akolahi’s picture

perfecto! THANKS!

akolahi’s picture

hmmm well it worked okay for a day... but i got the "Your site was unable to contact the Apache Solr server." error this morning. I will try again.

Is this supposed to be run from the example folder i.e. */solr-tomcat/apache-solr-nightly/example?

Thanks.

JacobSingh’s picture

Status: Active » Closed (fixed)

You should get support from solr-user@ mailing list for things directly related to running Solr.

kdes’s picture

@janusman

I ran the command "nohup java -jar start.jar >logfile 2>&1 &" and solr seems to be working fine even after I close SSH. But, where do I look for the process number ? It didn't output anything in my SSH window.

janusman’s picture

You can get the number of the last-run background process, from within a shell, with $!

For example, if you have this shell script: (you can paste this code into a file like run_solr.sh)

#!/bin/sh
cd /your/solr/install/directory/where/start.jar/lives

# Run the example Solr+Jetty implementation
nohup java -jar start.jar >logfile 2>&1 &

# Write the process ID into the file "pid"
echo $! > pid

echo "Done; running under process ID $!";
exit

You could then invoke this script from within the shell with "sh run_solr.sh" or the like.

You could add more bells and whistles like checking for errors (using $?) or killing an existing process (cat pid |xargs kill -9) etc.

It would probably be nice to have a full script for this in the future for everyone using the /example directory bundled with Solr. If there is real interest I could whip up one =)

janusman’s picture

Oh NTW I also came across this way to do it in PHP; probably *could* be a good thing to include some code to run a local Solr install from within Drupal?

http://bogdan.org.ua/2007/05/23/executing-and-checking-background-shell-...

Aurochs’s picture

fuf i hope it wont get off here - i had same problem.
is there any way to write it into some confirm file inside apachesolr?

raulmuroc’s picture

Version: 6.x-1.0-beta6 » 7.x-1.x-dev

The same solution.