1

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?

3 Answers 3

2

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.

2
  • 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, 2013 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. Feb 1, 2013 at 20:22
2

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.

0

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .