5

How can I run solr on a windows server, so it starts up automatically?

I run it with:

java -jar start.jar

but I need the server to do this automatically.

Blankman
  • 259,732
  • 324
  • 769
  • 1,199
  • I guess windows server can be started as a windows service and the java command itself could wrap into a bat file and also be added as a windows service: http://stackoverflow.com/questions/415409/run-batch-file-as-a-windows-service – Karussell Mar 28 '10 at 17:50

4 Answers4

7

Create a batch file with the command you need and run it on startup: some of these ideas might be of use.

If you ran solr inside tomcat, you could start tomcat as a windows service and set the service to start automatically.

Tomislav Nakic-Alfirevic
  • 10,017
  • 5
  • 38
  • 51
  • 3
    Can you explain more about how you are deploying a .WAR file inside of IIS? Or are you using IIS as a frontend to some other webcontainer? I think you can't deploy inside of IIS, that you need to have something like Jetty (which is what you are using with java -jar start.jar) or Tomcat. – Eric Pugh Mar 29 '10 at 10:55
  • Good point, Eric. IIS is not a servlet container: Blankman is probably simply using it as a frontend to jetty. In that case, my suggestion of using it with tomcat might make sense. Otherwise, Jetty can be set up as a windows service as well: http://docs.codehaus.org/display/JETTY/Win32Wrapper – Tomislav Nakic-Alfirevic Mar 29 '10 at 11:54
7

I've had good luck with the "Non-Sucking Service Manager" to do this exact thing. Very simple and lightweight: http://nssm.cc/

Tom Lianza
  • 4,012
  • 4
  • 41
  • 50
3

The Scheduled Tasks feature in Windows Server will let you configure your command to be executed at startup, without the use of a batch file.

Josh
  • 16,286
  • 25
  • 113
  • 158
1

I will add the small solr windwos service installer that I found and updated recently :

https://github.com/serbrech/SolrWindowsService

First Update the App.config

<add key="JavaExecutable" value="C:\Program Files (x86)\Java\jre6\bin\java.exe" />
<add key="WorkingDirectory" value="C:\Solr\apache-solr-4.0\example" />
<add key="Solr.Home" value="solr" />
<add key="CommandLineArgs" value="-Djava.util.logging.config.file=logging.properties" />
<add key="ShowConsole" value="false" />
<add key="Port" value="8983" />
<add key="InstanceName" value="Pageplanner" />
<add key="ClientSettingsProvider.ServiceUri" value="" />

Then run install.bat That's all there is to it.

Stéphane
  • 11,755
  • 7
  • 49
  • 63