Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I using using jetty to run Solr using the following cmd line: java -jar start.jar &

how can I stop this instance of solr gracefully?

share|improve this question

3 Answers 3

up vote 1 down vote accepted

Find the process id with ps and send it a signal to stop using kill - I believe the HUP or INT signals will allow the java process to gracefully exit; test to confirm.

Better yet, you should really be using a proper service to run Solr - Tomcat can do this, or Jetty can be made to run as a service.

share|improve this answer
    
I currently use ps and kill with HUP. I was hoping for a more elegant way, where I don't have to lookup the process ID and then send the kill HUP. –  Saqib Ali Feb 1 '13 at 12:32
    
@SaqibAli The elegant way to do it would be to set it up as a service via an init script - either by using a servlet engine like Tomcat that comes set up for that, or by setting one up for your Jetty process. –  Shane Madden Feb 1 '13 at 20:22

Just to clarify the previous answer, in the command:

java -DSTOP.PORT=8001 -DSTOP.KEY=stop_jetty -jar start.jar

The -DSTOP.PORT=port should specify an available port (different from the port configured in the solr_home/etc/jetty.xml used for Jetty). I tried in the next way to start it:

nohup java -DSTOP.PORT=8001 -DSTOP.KEY=stop_jetty -jar start.jar &

And just added the --stop parameter to stop it:

nohup java -DSTOP.PORT=8001 -DSTOP.KEY=stop_jetty -jar start.jar --stop &

In both cases is working fine but still it doesn't look gracefully enough.

share|improve this answer

Start it (defining stop.port and stop.key variables):

java -DSTOP.PORT=8080 -DSTOP.KEY=stop_jetty -jar start.jar

then you can stop it:

java -DSTOP.PORT=8080 -DSTOP.KEY=stop_jetty -jar start.jar --stop

source

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.