Reputation: 1
Since the logstash process on windows gets closed immediately after the connection to the machine is lost or logged off from the machine, How to keep the logstash process running continuously and in back-end on windows?
Upvotes: 0
Views: 1559
Reputation: 61
You can use the Windows Service Wrapper (https://github.com/kohsuke/winsw).
Simple put the wsw.exe into the logstash bin directory, rename it to logstash.exe and do the same for the configuration xml file. So you have a logstash.exe and logstash.xml file in the bin directory of logstash.
Now you need to adjust the xml file a bit. Mine looks like this (tweak it to your needs):
<configuration>
<id>logstash</id>
<name>Logstash</name>
<description>Logstash from elastic.co</description>
<executable>D:\logstash\bin\logstash.bat</executable>
<arguments></arguments>
<serviceaccount>
<domain>local</domain>
<user>waffel</user>
<password>XXX</password>-->
</serviceaccount>
<onfailure action="restart" delay="10 sec"/>
<onfailure action="restart" delay="20 sec"/>
<onfailure action="none" />
<resetfailure>1 hour</resetfailure>
<priority>Normal</priority>
<stoptimeout>15 sec</stoptimeout>
<stopparentprocessfirst>false</stopparentprocessfirst>
<startmode>Automatic</startmode>
<waithint>15 sec</waithint>
<sleeptime>1 sec</sleeptime>
<logpath>D:\logstash\logs</logpath>
<log mode="append"/>
<env name="JAVA_HOME" value="D:\jdk8x64" />
</configuration>
Then you can simple hit from the cmd (as admin)
logstash.exe test
Or to install the service
logstash.exe install
and then you can run from cmd (or service management)
logstash.exe start
logstash.exe stop
You may whatch the logsfiles for potential errors. For me it works fine with logstash 5.5.1
Upvotes: 0
Reputation: 1489
Use Non-Sucking Service Manager to install logstash as a windows service. Services can be started at boot and run without an active user login.
Upvotes: 1