De:WinServiceExample
Aus YaCyWiki
[service] appname = Yacy servicename = Yacy displayname = Yacy ;environment variable substitution is possible in any value ;e.g. ;jrepath=%JAVA_HOME% ;% is escaped by %% ;port used to communicate stop command to JVM ;Must be unique for each JSL instance installed ;This option is ignored if a stop method is defined further down ;stopport = 8465 ;delay n milliseconds to start the Java VM ;Default is no start delay ;startdelay = 10000 ;service dependencies can be added ;as a comma separated string "dep1,dep2" dependencies=Tcpip ;service start type ;auto demand disabled ;default is auto starttype=demand ;load ordering group loadordergroup=someorder ;account under which service runs ;default is system ;account=.\administrator ;password for above account ;system need not provide a password ;password=somewpd ;Allocate a console and register a console event handler to catch shutdown events. ;Default is true; options are FALSE TRUE false true YES NO yes no ;This option has two effects: ;1. If active it catches the logoff events and prevents the service from erroneously stopping in this case. ;2. It creates a console window if interaction with the desktop is allowd. ;Effect 1 can be achieved in Java 1.3.1 and higher by using the -Xrs option. ;Effect 2 may or may not be desired. ;useconsolehandler=TRUE ;Call <stopclass>.<stopmethod> through JNI so stop the JVM. ;This can be used an alternative to the ServiceStopper ;When all three parameters are defined the JSL will try to use JNI to stop the service. ;If not it will use a tcp/ip connection to the stopport. ;The simplest way to use this functionality is to use the Systen.exit() call as specified below. ;Nevertheless you can call any static method in your code. ;The method called is expected to terminate the JVM one way or the other. It can directly ;call System.exit() or make another Thread do it make the main method return. ;The method can return imediately if desired. If the JVM doesn't stop another attempt can be made to ;stop the service at a later time. ;stopclass=java/lang/System ;stopmethod=exit stopclass=yacy stopmethod=shutdown ;Take care to specify the right signature for your method. void System.exit( int code ) has ;the sifnature specified below. void myMethod() has the signature ()V. Please refer to the ;JNI documentation for details. ;stopsignature=(I)V stopsignature=()V ;Name and signature of service pause method. Will be called on a SERVICE_CTRL_PAUSE event. ;Please note that unless you have configured all pause and continue arguments ;you will not see the pause button enbaled in the service control manager GUI ;pauseclass=TelnetEcho ;pausemethod=pause ;pausesignature=()V ;Name and signature of service pause method. Will be called on a SERVICE_CTRL_CONTINUE event. ;Please note that unless you have configured all pause and continue arguments ;you will not see the pause button enbaled in the service control manager GUI ;contclass=TelnetEcho ;contmethod=cont ;contsignature=()V ;Value of the PATH environement variable being set by the service. ;PATH will remain unchanged if this is empty. ;path=c:\util ;Redirect C level stdout and stderr to the specified files ;Please note that those are diffrent files then the ones used below for ;Java level stdout and stderr ;Default is no redirection ;stdout=c:\stdout.log ;stdoutappend=no ;stderr=c:\stderr.log ;stderrappend=no ;Redirect JAVA level System.out and System.err to the specified files ;This simply sets new output streams for System.out and System.err after ;the JVM is initialized but before the main method is called. ;You might find that this option has no effect at all for some applications, as the ;JAVA application is of course free to redirect System.out and System.err ;to some other log mechanism. ;Default is no redirection ;Default is to overwrite file systemout=c:\systemout.log systemoutappend=yes systemerr=c:\systemerr.log systemerrappend=yes ;This method will be called before the main method of the start class specified on command line ;but after the JVM is fully initialized and stdout and stderr redirection have been performed. ;This method must return! It is called from the same thread as the main method. ;In order for the normal JVM start behaviour to continue this method must return 0. ;I may legally return any other value or throw any exception, which in both cases will result in ;a regular termination of the JVM much in the same way as if an uncatched exception had been thrown ;in the main method. ;It may legally start other threads in the JVM, which will behave in the same way as started from ;the main method. ;In fact you will be able to produce pretty much the same behaviour as calling the static method first in ;your main method. ;The example method present here is a scheduler which will in turn run the code specified ;in its modules list. Some utilities are provided. ;premainclass=com/roeschter/jsl/PreMainScheduler premainmethod=run premainsignature=()I premain.modules=threaddump premain.threaddump.class=com.roeschter.jsl.ThreadDumpListener premain.threaddump.method=start premain.threaddump.wait=3000 premain.threaddump.critical=no premain.threaddump.interface=127.0.0.1 ;Report service stopped on exit of main thread ;you might want to set this to yes if your service terminates "silently" ;It is recommended that a service is stopped by calling System.exit() at some time, ;either externally or internally. This provides a nice and clean shutdown hook. ;If the service terminates silently but just ending the last thread this might result ;in the service manager not recognizing the fact and denying restart. Use yes in this case. ;It should usually be safe to use reportservicestoppedonmainthreadexit=true ;even if you use otehr threads then main. The shutdown code will wait for non daemon threads to stop ;I can't remember why I made this parameter optional. It must have been useful for some people or in some situations ;Default is no ;reportservicestoppedonmainthreadexit = no ;Behaviour in case of JVM exiting with an error ;Define whether an execption in the main method should be considered an error ;Use this exit code in case of an exception. ;exceptionerrorcode=0 ;Desired behaviour for a non zero exit code (including exceptions as specified above) ;Options: ;ignore terminate without error (default) ;returncode exit with error code reported by the JVM to to the service manager ;fatal don't report regular service stop to service manager making it believe ;a fatal error had occured in the service (this is sometimes desirable if fatal error ;recovery mechanisms are in place) ;onexiterror=fatal ;Use this executable for registering the service. ;Default is the executable used for installation ;modulepath="e:\java\test\jsl_0_9_9e\release\jsl.exe -ini e:\java\test\jsl_0_9_9e\release\jsl2.ini" [java] ;Path to the java runtime used ;If this option is not used the default from the registry will be used ;jrepath=c:\java\jdk15 ;Type of jvm to be used. Alternative mechanism to specifiying -client or -server on the command line. ;Can use any JVM name, which is diffrent from the command line which will only allow -client and -server ;Useful when using JVM diffrent from Suns implementation. ;jvmtype=server ;working directory ;wrkdir=e:\java\test wrkdir=C:\yacy ;the number of paramters passed to the java application ;parameters must be named param00, param01 ... ;Please note that each command line parameter has to go on it's own parameter value here! ;The way the JVM is called in JSL, the JVMexpects a preparsed array of parameters. ;Everything seperated by whitespace on a java command line is broken down into a parameter here. ;You won't need to care about quotes ;around string containing spaces here. e.g. ;java.exe -cp "c:\program files\test\lib.jar" com.test.Java "test.>" ;becomes ;params = 4 ;param00 = -cp ;param01 = c:\program files\test\lib.jar ;param02 = com.test.Java ;param03 = test.> ;params = 6 ;param00 = -cp ;param01 = e:\java\test\jsl_0_9_9e\src ;param02 = com.roeschter.jsl.StopTest ;param03 = -exitMain ;param04 = -startThread ;param05 = -callExitThread params = 5 param00 = -Xmx256m param01 = -Xms256m param02 = -cp ;Die folgende Zeile orientiert sich an YaCy SVN Rev. 3382 vom 20.02.2007 param03 = classes;yacy.jar;htroot;lib\commons-collections.jar;lib\commons-pool.jar;libx\wsdl4j.jar;libx\xerces.jar;libx\jdom.jar;libx\jaxrpc.jar;libx\jsch-0.1.21.jar;libx\PDFBox-0.7.2.jar;libx\tar.jar;libx\commons-discovery.jar;libx\odf_utils_05_11_29.jar;libx\axis.jar;libx\log4j-1.2.9.jar;libx\jrpm-head.jar;libx\axis-ant.jar;libx\commons-logging.jar;libx\bzip2.jar;libx\tm-extractors-0.4.jar;libx\jmimemagic-0.1.0.jar;libx\jakarta-oro-2.0.7.jar;libx\saaj.jar;libx\commons-codec-1.3.jar;libx\informa-0.6.0.jar;libx\activation.jar;libx\commons-jxpath-1.1.jar;lib\svnRevNr.jar;libx\gnumail.jar;libx\inetlib.jar;libx\poi-3.0-alpha2-20060616.jar;libx\poi-scratchpad-3.0-alpha2-20060616.jar;libx\sbbi-upnplib-1.0.3.jar;libx\webcat-0.1-swf.jar param04 = yacy