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?

Saqib Ali
  • 410
  • 2
  • 7
  • 19

3 Answers3

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.

Shane Madden
  • 112,982
  • 12
  • 174
  • 248
  • 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 01 '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 01 '13 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.

Signal15
  • 943
  • 7
  • 27
2ark0
  • 21
  • 3
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

Amr Lotfy
  • 101
  • 2