Solr Windows Service won't stop

1.3k Views Asked by At

I have Solr set up on my server and running as a service, everything runs beautifully until I come to try and stop the service, it just hangs. I have tried amending the arguments and spent forever trying to see if anyone has got the same problem. unfortunately my google fu has failed me.

Service is set up as per the below using the Commons Daemon Service Runner.

@echo off

set JAVA_HOME=D:\application\Java
set SERVICE_NAME=SolrService
set SERVICE_HOME=D:\application\Solr
set PR_INSTALL=%SERVICE_HOME%\server\SolrService.exe

@REM Service Log Configuration
set PR_LOGPREFIX=%SERVICE_NAME%
set PR_LOGPATH=%SERVICE_HOME%\logs
set PR_STDOUTPUT=auto
set PR_STDERROR=auto
set PR_LOGLEVEL=Debug
set PR_STARTUP=auto
set PR_STARTMODE=exe
set PR_STARTIMAGE=%SERVICE_HOME%\bin\solr.cmd
set PR_STARTPARAMS=start

@REM Shutdown Configuration
set PR_STOPMODE=exe
set PR_STOPIMAGE=%SERVICE_HOME%\bin\solr.cmd
set DSTOP.PORT=8983
set PR_STOPPARAMS="stop -p 8983 -k solrrocks"

%PR_INSTALL% //IS/%SERVICE_NAME% ^
  --Description="Solr-5.2.1 Search Tool for Application" ^
  --DisplayName="%SERVICE_NAME%" ^
  --Install="%PR_INSTALL%" ^
  --Startup="%PR_STARTUP%" ^
  --LogPath="%PR_LOGPATH%" ^
  --LogPrefix="%PR_LOGPREFIX%" ^
  --LogLevel="%PR_LOGLEVEL%" ^
  --StdOutput="%PR_STDOUTPUT%" ^
  --StdError="%PR_STDERROR%" ^
  --StartMode="%PR_STARTMODE%" ^
  --StartImage="%PR_STARTIMAGE%" ^
  --StartParams="%PR_STARTPARAMS%" ^
  --StopMode="%PR_STOPMODE%" ^
  --StopImage="%PR_STOPIMAGE%" ^
  --StopParams="%PR_STOPPARAMS%"

if not errorlevel 1 goto installed

echo Failed to install "%SERVICE_NAME%" service.  Refer to log in %PR_LOGPATH%

exit /B 1

:installed
echo The Service "%SERVICE_NAME%" has been installed

exit /B 0
1

There are 1 best solutions below

2
On BEST ANSWER

Used NSSM to resolve the issue and manage the windows service https://nssm.cc/

Made a batch file that contains the following information (run from the same location as your NSSM.exe)

nssm install D:\Search\bin\solr.cmd

nssm set AppDirectory D:\search\bin

nssm set AppParameters "start -f -p 8983

nssm set Description "Solr Search Engine Windows Service"

That will create a windows service that should start and stop correctly