Skip to content

Instantly share code, notes, and snippets.

@vegaasen
Last active August 29, 2015 14:18
Show Gist options
  • Save vegaasen/48a69c5d4d31c047a217 to your computer and use it in GitHub Desktop.
Save vegaasen/48a69c5d4d31c047a217 to your computer and use it in GitHub Desktop.
Windows Service bat example
@ECHO OFF
REM
REM This script requires the following system variable to be registered:
REM key: DIFI_CONFIG_HOME
REM value: C:\path\to\difi\configuration\vefa-validator-conf-master
REM
REM @author vegaasen
REM @version 0.1
REM @since 31.03.2015
IF "%DIFI_CONFIG_HOME%." == "." GOTO :MissingRequiredAttributes
@ECHO ON
echo Using "%DIFI_CONFIG_HOME%" as the configuration home
@ECHO OFF
REM -- Configuring service related stuff
SET PORT=7007
set PR_PATH=%CD%
set SERVICE_NAME=DIFIValidator
set PR_DESCRIPTION=DIFIValidator is used in regards to the invoice central
set PR_INSTALL=%PR_PATH%\prunsrv.exe
REM -- Service log configuration
set PR_LOGPREFIX=%SERVICE_NAME%
set PR_LOGPATH=%PR_PATH%\logs
set PR_STDOUTPUT=%PR_LOGPATH%\stdout.txt
set PR_STDERROR=%PR_LOGPATH%\stderr.txt
set PR_LOGLEVEL=Debug
REM -- Path to java installation
set PR_JAVAHOME=%PR_PATH%\java
REM -- Startup configuration
set PR_STARTCLASS=no.difi.vefa.ws.run.StartServer
set PR_STARTMETHOD=main
set PR_STARTUP=auto
set PR_STARTMODE=Java
REM -- Note; set this to whatever port you'd like. Default is that the service listens to port 7007 :-)
set PR_STARTPARAMS=start;%PORT%
set PR_CLASSPATH=%PR_PATH%\validate-ws-1.0.0.jar
REM -- Note; the stop stuff does not work at the moment :-|
REM Shutdown configuration
set PR_STOPMODE=Java
set PR_STOPCLASS=no.difi.vefa.ws.run.StartServer
set PR_STOPMETHOD=main
set PR_STOPPARAMS=stop;%PORT%
REM -- JVM configuration
set PR_JVMMS=384
set PR_JVMMX=384
set PR_JVMSS=4000
set PR_JVMOPTIONS=-Dno.difi.vefa.validation.configuration.datadir=%DIFI_CONFIG_HOME%\\validator.properties -Dcom.sun.management.jmxremote.port=3333 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false
REM -- Remove previous installed versions
prunsrv.exe delete %SERVICE_NAME%
REM -- Install service
prunsrv.exe install %SERVICE_NAME%
REM -- Start service
REM prunsrv.exe start %SERVICE_NAME%
@ECHO ON
echo Service {%SERVICE_NAME%} is now configured and registered.
@ECHO OFF
GOTO Done
:MissingRequiredAttributes
echo It seems like the required system variable "DIFI_CONFIG_HOME" is not set. Unable to continue.
:Done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment