Skip to content

Instantly share code, notes, and snippets.

@epu
Last active December 24, 2015 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save epu/6781909 to your computer and use it in GitHub Desktop.
Save epu/6781909 to your computer and use it in GitHub Desktop.
logstash cmd file wrapper based around the cookbook. had to forward slash --config file option (bug? --log works ok..)
:: http://cookbook.logstash.net/recipes/windows-service/
@setlocal
@set LOGSTASH_DIR=%~dp0
:: it would be nice to symlink the jar into logstash.jar with mklink, so name never changes. -epu
@set LOGSTASH_JAR=%LOGSTASH_DIR%logstash-1.2.1-flatjar.jar
@set LOGSTASH_CONF=%LOGSTASH_DIR%%~n0.conf
:: I know, right? the logger log!
@set LOGSTASH_LOG=%LOGSTASH_DIR%%~n0.log
:: Why did we set this? Why forward slashing?
@set HOME=c:/logstash/sincedb
:: locally, this is an x64 java.
@set JAVA=%JAVA_HOME%\bin\java.exe
@set OPTIONS=-Xmx32M
@set OPTIONS=%OPTIONS% -jar "%LOGSTASH_JAR%"
@set OPTIONS=%OPTIONS% agent
:: --config doesn't accept windows backslashes in path. D:
:: but --log does? Yeah. Log does. Flipping them both anyways.
:: from set /? -- replace text in a variable with %PATH:str1=str2%
@set OPTIONS=%OPTIONS% --config "%LOGSTASH_CONF:\=/%"
@set OPTIONS=%OPTIONS% --log "%LOGSTASH_LOG:\=/%"
@pushd "%LOGSTASH_DIR%"
"%JAVA%" %OPTIONS%
@epu
Copy link
Author

epu commented Oct 1, 2013

I had to install service as c:\windows\system32\cmd.exe /K c:\logstash\logstash.cmd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment