Home
Login
Register
Search
Home
YAJSW - Yet Another Java Service Wrapper - Introduction
YAJSW - Yet Another Java Service Wrapper - Introduction
March 25, 2018 | Author: Gottipati Sree Harsha | Category:
Command Line Interface
,
Java (Programming Language)
,
Cross Platform
,
Microsoft Windows
,
Computing Platforms
DOWNLOAD
Share
Report this link
Comments
Description
YAJSW - Yet Another Java Service Wrapper - Introductionhttp://yajsw.sourceforge.net/ Welcome to YAJSW Yet Another Java Service Wrapper 1. Welcome to YAJSW 1. 1. Introduction 2. Project information 3. Changes 4. Comparison of wrapper frameworks 5. Requirements & Supported Platforms 6. Features 7. Quick Start 1. View Screencast 2. Installation of a java application using genConfig 8. Migrating from JSW 9. Configuration 10. Configuration Generator 11. Java Application Launching 12. Using YAJSW from within a java application 1. Starting a native image 2. Starting a java application 3. Reading the output stream of a wrapped application 4. Writing the input stream of a wrapped application 5. Restarting/Stopping the JVM from within a wrapped application 6. Getting a Thread Dump of the wrapped application 7. Installing a service 8. Starting a service 9. Stopping a service 10. Listening to state change 13. Monitoring java applications 1. Monitoring Heap 2. Monitoring Memory 3. Monitoring Deadlocks 14. Timers and Conditions 15. JMX Support 16. System Tray Support 17. Windows services 18. Unix/Linux Daemon 19. Mac OS X Daemon 20. Scripts 1. Shell Scripts 2. Groovy Scripts 3. Sample Scripts 4. Condition Scripts 5. Testing a script 21. MSCS Cluster Aware Wrapper 22. Windows Session0 Isolation 23. OS Users 24. Entering passwords 25. YAJSW lib folder 26. Wrapper process java options 27. Wrapping groovy scripts 28. YAJSW groovified: WrapperBuilder 29. Building YAJSW 30. Network Launching of Applications - Experimental 31. Wrapping JNLP - Experimental 32. Java Web Start Support - Experimental - Currently only for windows 33. Services Manager - Experimental - Currently only for windows 34. Android Services Manager - experimental 35. Third party Libraries Introduction YAJSW is a java centric implementation of the java service wrapper by tanuki (JSW). It aims at being mostly configuration compliant with the original. It should therefore be easy to switch from JSW to YAJSW. 1 of 21 8/4/2011 4:07 PM YAJSW - Yet Another Java Service Wrapper - Introduction http://yajsw.sourceforge.net/ JSW is a wonderful software I have been using for some time in production. So why yet another framework ? The main reason is that I need a better integration within my java job scheduling framework (rzomx) As of the next version the license of JSW will change making it impossible for me to use it in rzomx I may need win64 support, which is currently not available or not free for JSW. Project information YAJSW project is managed on sourceforge Please refer to the project page for licensing, user forums, bug tracking, file downloads. Currently the project does not support mailing lists nor does it support a source code repository. The source is included in the download file. Changes Comparison of wrapper frameworks YAJSW : Yet Another Java Service Wrapper JSW : Java Service Wrapper ACD : Apache Commons Daemon L4J : Launch4j Note: If you would like to add further frameworks or in case of errors in the table please inform me. Features/Framework License Run as Windows Service Run as UNIX Daemon Support Mac OS X launchd Platform indepemdent installation of services/Daemons Java Embedable Wrap Java Application Wrap Groovy Script Wrap native executable Wrap as executable Portable Configuration Capture and Log console output Stop and Reconnect Wrapper Monitor Application Restart Application Single Instance Enforcement Control Process Priority Control Process Affinity Alert Emails Scripting Timed Events and Event commands Configuration generator Define Process Name Automatic selection of JVM JMX Support X X X X X X X X X X X X X X X X X (Commercial) X (Commercial) X X X X X X X X YAJSW LGPL X X X X X X X X X X X JSW GPL/Commercial X X ACD Apache X X 2 of 21 8/4/2011 4:07 PM 5 The current release is alpha for Solaris Tested on Solaris 10 u6 x86 The current release is alpha for FreeBSD Tested on FreeBSD 7. NOTE Windows vista. Monitoring Console. Ubuntu 10.Introduction http://yajsw.4 32 & 64 bit The current release is alpha for Mac OS X Tested on 10.bat". 7. Features Wrap any native executable. Display tray messages from a groovy script. Windows 2008 32 & 64 bit. times or scriptable conditions Embed the wrapper within java applications Read from process output or write to process input Support for RunAs / sudo Support for System Tray Icon. trigger scripts or restart process on output matching regular expressions Monitor and automatically restart hanging or crashed proceses Trigger process execution and termination at specific cycles.sourceforge.1 x86 and amd64 Goal of YAJSW is to support all platforms as JNA. Ubuntu 9. Support for generation of configuration file Windows Cluster aware Support for remote network launching Support for jnlp configuration License: LGPL Quick Start View Screencast Installation of a java application using genConfig Note: In the sequel script file names end with ". Windows 2000 server. Windows 2003 32 & 64 bit server. etc: the batch files have to be run as administrator.Yet Another Java Service Wrapper . Tested on Suse 9.5. java process or groovy script and run it as windows service or linux daemon Easy Platform Independent installation of services/daemons Platform independent configuration Support for platform specific configuration Wild card for classpath directories and files Capture console output. for example in case of exceptions.YAJSW .1 x86 and amd64. The current release is stable for win32 and win64 Tested on: Windows XP prof. Windows Vista The current release is stable for Linux. Suse 11.5 or higher.04 32 & 64 bit. log it. For Linux please use the corresponding files which end with ".sh" download YAJSW 3 of 21 8/4/2011 4:07 PM . or ported it on other platforms please notify me.net/ System Tray + GUI Console Windows Cluster Aware Network launcher Support JNLP configuration Java Webstart launcher X X X X X Requirements & Supported Platforms YAJSW requires Java 1. It should be easy to build it for other platforms supporting libffi If you have tested it. Windows 7 32 & 64 bit. You may have to edit this property. For example start Tomcat.WrappedProcess.bat To uninstall the service: uninstallService.bat or setenv.YAJSW .java configuration in system properties will override the OS environment.conf file with a text editor.java system properties (example -Dwrapper. Use the file conf/wrapper.java=c:\java\jdk1. Do not remove or copy files from this folder to any another folder. there are cases where system properties of the wrapper should not be used by the wrapped application.6 is required.conf") ) . Properties can be defined in: .conf with a text editor and set the password for wrapper.ntservice. 4 of 21 8/4/2011 4:07 PM . Configuration Configuration is mostly identical to JSW. Start the application you would like to wrap.5 or higher If this is not the case make sure that java 1.6 is required.sourceforge.config". The configuration generator helps you generate the configuration. Execute your wrapped application as console application by calling runConsole. NOTE: we need the pid of the application not the batch file which started the application.conf.conf which is the configuration file for wrapping your application Stop your application Open conf/wrapper. which starts a java application which prints some numbers on the console.setProperty() . Thus setting wrapper. Call java -version and make sure that your default java installation is 1. Do not rename any folders within <yajsw>.bat To start the service: startService. NOTE: In case of cascading wrapper applications.wrapper.sh. Goto yajsw/bat and execute genConfig.conf file .setProperty("wrapper.app.net/ Unpack the zip file to a folder <yajsw>.setUseSystemProperties(false).account (#). NOTE: configuration generation is currently implemented only for java applications.ini as starting point. For native images or groovy scripts you will have to create the wrapper.bat check that your application (for example tomcat) is running To Install the application as service call installService.bat. Configuration Generator Creating a wrapper configuration file can be quite a nuisance. For this you may have to change the manifest in the jar files. when starting sub processes. or System. To change the configuration first stop the wrapper and the application. You may use bat/runHelloWorld. Check the process id of your application.password or comment out wrapper. NOTE: Do not change the configuration or scripts while the wrapper or application or service or daemon is running.in wrapper.5 or higher is installed and adapt the environment variable java_exe in bat/setenv. YAJSW however follows a diffrent architecture and therefore supports the JSW integration methods differntly. Detailed description of the YAJSWconfiguration properties is found here.5\bin\java. A migration guide for JSW users has therefore been implemented.bat <pid> NOTE: on posix systems (Linux) this command requires root priviliges to access information on other processes This generates the file yajsw/conf/wrapper.working.conf. NOTE: to display system tray java 1. Also check the value of wrapper. "conf\wrapper. For thread dump with locks java 1.dir is currently not determined automatically. This can be avoided by calling WrappedProcess.Yet Another Java Service Wrapper . It will be implemented for native image and groovy in a later release.exe) Properties are searched in this order.as operating system environment variables (example for win32: set wrapper.bat To stop the service: stopService.Introduction http://yajsw.getLocalConfiguration().app. Solaris: wrapper.bat command line attributes . NOTE: Before changing service/daemon configuration properties: stop and uninstall the service or daemon. NOTE: Mac OS X. Given a process id (pid) the configuration generator examines the command line of a running process and automatically generates a configuration file for wrapping the given application.name NOTE: you may also create a configuration file with a text editor.bat Migrating from JSW YAJSW configuration and command line interface are very similar to those of JSW.config=conf\wrapper. net/ Usage: wrapper.getLocalConfiguration(). // initialiase the process w. // a drain warps access to the output and error streams of the wrapped process.start(). WrappedProcess w = (WrappedProcess) WrappedProcessFactory.createProcess(new HashMap()). Reading the output stream of a wrapped application WrappedProcess w = (WrappedProcess) WrappedProcessFactory.init(). The process does not hang if the output is not consumed.getLocalConfiguration(). Map configuration = new HashMap().app. WrappedProcess w = (WrappedProcess) WrappedProcessFactory. // start the process w.parameter.createProcess(configuration).1". These functions may also be embeded within a java application. restart.app.mainclass".put("wrapper.setProperty("wrapper. // start the process w. // initialiase the process w.app. <main class>).config". NOTE: currently the configuration generator only generates configurations for java applications.start().setProperty("wrapper.createProcess(configuration).waitFor(10000). // initialiase the process w. <conf file>). scripts etc. // a drain must be started and stopped 5 of 21 8/4/2011 4:07 PM .Introduction http://yajsw.sourceforge.image".start(). Java Application Launching The internal workings of application launching and classloading are described here. // process specific configuration w. which are not available in the command line of the current process.init().stop(). // start the process w.waitFor(10000). Using YAJSW from within a java application YAJSW may wrap applications through the shell scripts in <yajsw>/bat. "notepad. Starting a native image // configuration Map configuration = new HashMap(). "hello").java.Yet Another Java Service Wrapper . // stop the process w.bat -g <pid> [-d <default configuration file>] <output file> pid: process id of the process to wrap <output file> : name of the output configuration file <default configuration file> : optional input file for defining properties such as logging. // system properties overwrite properties in conf file. Starting a java application // global configuration System.stop().parameter. // stop the process w.setProperty("wrapper.exe"). w. "hello"). / process specific configuration w.YAJSW .setProperty("wrapper.1". NOTE: the configuration generator should not be used for processes which are already wrapped.init(). // wait at most 10 sec or until process termination w. configuration. System. out.setPropery("wrapper.addStateChangeListener(WrappedProcess.WRAPPER_MANAGER. Installing a service System. w. w. // start the service Starting a service WrappedService w = .stop()..Yet Another Java Service Wrapper . w. <conf file>). // stop the service Listening to state change WrappedProcess w =. w. w.println(w.. // read in configuration w. Writing the input stream of a wrapped application WrappedProcess w = (WrappedProcess) WrappedProcessFactory..yajsw. // read in configuration w.stopDrain(). .yajsw.rzo.createProcess(new HashMap()).start(). // read in configuration w. // start the process w. new StateChangeListener() { 6 of 21 8/4/2011 4:07 PM .WrapperJVMMain.restart().YAJSW . Getting a Thread Dump of the wrapped application WrappedJavaProcess w = . // initialiase the process w.app.app. // get a print stream to the process PrintStream out = (PrintStream)w. if no output is available the output stream is consumed w...STATE_ABORT.init().start(). System. WrappedService w = new WrappedService().init().getOutputStream().println("my password").config".init(). org.WRAPPER_MANAGER.init().init().rzo.stop(). // run the service Stopping a service WrappedService w = . Restarting/Stopping the JVM from within a wrapped application org..WrapperJVMMain. w.startDrain().net/ // the drain maintains a circular buffer // if since last call to readDrainLine() no new output has been generated then "null" is returned // if readDrainLine() is not called for a "long time" the buffer may overflow and you may "miss" some of the output // the drain first consumes the error stream.Introduction http://yajsw.in of the process out.sourceforge.readDrainLine()).install()..requestThreadDump(). w.. // initialiase the process w..waitFor(). // send some text to System.. deadlock = true When a deadlock is detected the following text is printed to System.script.start().heap = true wrapper.integer}" is a java MessageFormat pattern which is formatted with the following arguments: Used Heap. "process could not be started"}).com. {1\.threshold.number\.execute().monitor.deadlock: DEADLOCK IN THREADS: wrapper. Monitoring Memory to enable set: wrapper.(see rdd4j) Monitoring Deadlocks to enable set: wrapper.heap: HEAP SIZE By setting a triffer on this text one can execute actions or scripts. {1\.java. {2\.heap. w.filter. }).java.java.monitor.filter.threshold.err: wrapper. Monitoring java applications YAJSW implements features helping you to monitor your java applications.number\.err when the garbage collector has been executed. You can set your own pattern and write a program which scans the log file to analyze the heap requirements of your applicaiton.trigger.java.number\. int oldState) { Script script = ScriptFactory.integer}\. script.monitor. Java low on memory set java option -Xmx to a higher value or check for memory leaks.createScript("scripts/sendMail.heap: HEAP SIZE wrapper.integer}\. Currently the following monitors have been impelemented: Memory Deadlocks Monitoring Heap to enable set: wrapper.java. Example: Monitor for deadlocks.mail=scripts/sendMail.number\.mail.monitor.number\. for later display or analysis.java. display a tray icon message and restart the application if a deadlock is detected: wrapper. Minor GC Duration.heap.mail=wrapper.err: wrapper. You could also use a trigger and script to write the data to a database.monitor.deadlock.heap.monitor.java.script.tray=wrapper.gv 7 of 21 8/4/2011 4:07 PM .script. Example: send an email if the used heap exceeds 90%: wrapper.java.monitor.percent = 90 If the current used heap size exceeds 90% of the maximal heap size the following message is printed to System.percent = 20 wrapper.heap.heap.YAJSW
[email protected]
}\.gv".deadlock: DEADLOCK IN THREADS: A thread dump of the threads involved is also printed. A GC duration is 0 if it has not been executed.filter.gv wrapper.deadlock.filter.monitor.com". {2\.filter.java.Introduction http://yajsw.monitor. "some id". The formatted text is logged to System.trigger. Full GC Duration.number\.sourceforge.Yet Another Java Service Wrapper .integer}\.monitor.net/ public void stateChange(int newState.deadlock=true wrapper. By setting a trigger on this text one can execute actions or scripts. new String[{"
[email protected]
=MYGC: {0\.tray=scripts/trayMessage. w.integer} The text "MYGC: {0\. timer.java.txt wrapper.timer.condition.deadlock.cycle=1 When using Timers or Conditions the functionality of the start() and stop() methods may be confusing.args=Deadlock Detected wrapper.gv: This script checks for the presence of a command file.deadlock.jmx.sourceforge.script=scripts/timeCondition.script. if port 1099 is not free set wrapper.jmx.rmi.trigger.condition. If a timer is defined the wrapper service runs as long as the timer is active.password To activate JMX support for the wrapped application: add the property wrapper. The first call to start() will trigger the timer or condition.Introduction http://yajsw.timer. To activate JMX support on the wrapper: add the property wrapper.jmx=true to the configuration file. YAJSW includes the following sample condition scripts: timeCondition. If the file is present the content of the file is read and the command in the file is executed. The wrapper uses the Quartz framework to start/stop the application.Yet Another Java Service Wrapper . A condition is agroovy script which is executed at fixed time intervals or only once. Configuration Example: wrapper.script=scripts/commandCondition.1:50 will start the application at 23:00 and will stop it at 1:50 the next day.jmx.management.condition.sun.condition.restart=wrapper.filter.filter.rmi.script.cron.net/ wrapper. <cmd>.user wrapper.<n>=-Dcom.jmx=true to the configuration file add the property wrapper.port=<a free port> To activate authentication the credentials may be defined in the configuration: wrapper.java.monitor.FIRST is not defined.restart=RESTART Timers and Conditions A timer allows one to automatically start/stop/restart the application at specific times or intervals.rmi.filter.action.gv wrapper. If a timer is defined the first call to start() will start the application only if the property wrapper. Subsequent calls to start() will start the application.script.java. The script controls the start/stop of the application.tray.condition.additional. commandCondition.gv wrapper.deadlock.simple. If a condition is defined the first call to start() will not start the process.START or wrapper.gv: This script will make sure that the process is running between the specified times: Configuration Example: wrapper.args=23. A call to stop() will stop the application. Example: wrapper.jmxremote to the configuration file 8 of 21 8/4/2011 4:07 PM .args=cmd.RESTART.cron=* * 0/12 * * ? Starts the process immediatly and restart the process daily at 00:00 and 12:00 h. To cancel the timer use the method stopTimer() To cancel the condition use the method stopCondition() JMX Support JMX Support is available for the wrapper and for the wrapped application.deadlock: DEADLOCK IN THREADS: wrapper.YAJSW . message) TrayIcon. The exit wrapper menue will stop the wrapper. depending on the application cleanup time. Per configuration file only a single tray icon process can be started.info(caption.tray. Solaris: Currently wrapper. The console menue will open a window displaying the console output of the application. If not defined. message) TrayIcon. on windows.sourceforge.jar -y <conf file>". The wrapper process will then control and monitor the application. may require extra time. You may define your own icon to be displayed by setting the property wrapper. npg.warning(caption. a windows 1503 error message is displayed. gif can be used.Introduction http://yajsw.interactive is not automatically handled by YAJSW. Windows services When starting a windows service the service is displayed as running as soon as the wrapper is up.name> or "?" System Tray Support YAJSW offers support for system tray.title> or <service. the SCM snap-in timeout.tray = true The System Tray Icon is started in a separate process which communicates with the wrapper through netty asynchronous hessian. You will have to make sure that DISPLAY is exported and xhost + is called. System tray is activated by setting the property wrapper.control property and the defined script properties. The java system tray is available only for Sun JDK 1. When running the wrapper as a service the tray icon has to be started separately.bat starts the process for the default configuration file. the process will exit.error(caption.icon=<full path to image file>. the wrapper. The icon size is automatically scaled to fit the size required by the OS. message) A sample script is provided for displaying an exception in case an exeption is logged on the console.net/ The name of the YAJSW MBeans are: Wrapper:name=<cosole. FreeBSD: System tray is currently not supported. The port for communication is boradcasted using multicast discovery. The exit menue will close the Tray Icon. Stopping a service. The service will continue to with the cleanup. The batch script systemTrayIcon.Yet Another Java Service Wrapper .5 or higher the program will detect if system tray is supported. The System Tray process is automatically started if the application is started as console. If a process is started while another process is already running.6 or higher. The process can be started by calling "java -jar wrapper. After 2 minutes.message(caption. NOTE: Mac OS X. restarting. create a link to start the try icon from the startup folder. That is for displaying a status icon and menue on the desktop. This message does not mean that the service is forcibly killed. When the window is closed the application continues to run. Timeouts are controlled by the wrapper using the according 9 of 21 8/4/2011 4:07 PM . Using groovy scripts you may display notification messages: Access the system tray icon: process. NOTE: Linux. One may for example. where caption is the header of the message and message is the content: TrayIcon. These however do not stop the wrapper. File formats supported by java such as jpg. Since YAJSW requires JDK 1. The state of the application is displayed by a colored circle on the icon. RED GREEN ORANGE BLACK == IDLE == RUNNING == other (starting.ntservice.getTrayIcon() The following methods are available.YAJSW . a default icon is used. message) TrayIcon. stopping) == OFFLINE (no communication with the wrapper) The system tray offers menues for starting stopping and restarting the application. Per default the scripts are placed in the . Scripts may either be wrapped or they may be invoked from within the wrapper triggered by state changes or by matching expressions to the console output or as conditions which may control job executions. Shell Scripts 10 of 21 8/4/2011 4:07 PM . .ntservice. For now you will have to execute the scripts within a user which has the required rights.ntservices.<wrapper. The plist file is placed in the directory <wrapper.ntservices. For this the launchd utility is used.dir> The plist file name is: wrapper.pid wrapper.<wrapper.daemon.pid and are placed per default in the directory <wrapper.dependencies is not supported.template is used to generate the plist file.groovy) scripts.name>.ntservice.ntservice. See Configuration documentation for further properties.name>. Wrapping groovy scripts is described in the sequel.java. These functions are also accessible through the API of WrappedService -i : install a daemon script wrapper.dir> -p : stop the daemon -q : query the state of the daemon -qs : silent query of the daemon state NOTE: Currently wrapper.name>.YAJSW .name> -r : remove the daemon script -t : start the daemon starting the daemon creates the files <wrapper.template is a velocity script used to generate the daemon script.Yet Another Java Service Wrapper .gv.plist The label key is: wrapper. YAJSW offers the following functions. Here we describe scripts which are executed on state change or triggered by console output or as conditions.daemon.java. It will be supported in future release.sourceforge.dir> The daemon script is named <wrapper. per default these files are named wrapper.net/ configuration properties.name> launchctl load <plist file> is called to install the file -r : remove the daemon launchctl unload <plist file> is called the plist file is removed -t : start the daemon launchctl start <plist label> is called -p : stop the daemon launchctl stop <plist label> is called -q : query the state of the daemon launchctl list is called and the result is analysed to check if the daemon is installed and if it is running -qs : silent query of the daemon state NOTE: currently users are not properly handeled by YAJSW. Scripts YAJSW supports shell (. A builder for easy interface to YAJSW from within groovy scripts is also described later. Unix/Linux Daemon YAJSW tries to support users with little or no Unix/Linux knowledge by offering similar functions as for windows services.ntservice.pid.pidfile>.<wrapper. The script is placed in the directory <wrapper.launchd. Mac OS X Daemon YAJSW tries to support users with little or no Mac OS X knowledge by offering similar functions as for windows services.pidfile> and <wrapper. It will be supported in future release. YAJSW offers the following functions.plist.ntservice.Introduction http://yajsw.bat. NOTE: Currently wrapper.sh) and groovy (. This will be implemented in future release.dependencies is not supported./scripts folder. These functions are also accessible through the API of WrappedService -i : install a daemon wrapper.<wrapper.daemon. These are used to stop the daemon or to check the status of the daemon. . sourceforge. Negative if the process has not exited line the output line of the console.gv make sure the process is running depending on existance of an achor file timeCondition.<n> state the current state of WrappedProcess. Negative if the process is not running exitCode exit code of the process. Grooy scripts are executed with the following default bindings: args arguments defined in the .args property Groovy Scripts Groovy scripts offer much more flexibility and enable calls to the WrappedProcess. in case the script was triggered by a filter or a regular expression process WrappedProcess context a static map. Refer to the scripts folder for further scripts. no user defined variables are bound in the script.Yet Another Java Service Wrapper .net/ Shell scripts are called with the following arguments: id <n> from wrapper.gv send an email snmpTrap. Note: When the script is first called.filter. sendMail.gv make sure the process is running in a time interval commandCondition.gv display a message on the system tray. defined in Constants. They are thus highly performat and maintain their bindings inbetween calls. defined in Constants.YAJSW .STATE_* count the number of failed invocations pid the pid of the process.args property callCount counter of script invocation.gv send an snmp trap trayMessage. in case the script was triggered by a filter or a regular expression args list of arguments are defined in the .Introduction http://yajsw. Negative if the process is not running exit code exit code of the process.STATE_* count the number of failed invocations pid the pid of the process. allowing to share data between scripts Sample Scripts The following sample groovy scripts have been implemented. Refer to the script file for documentation on how to use it. starting with 0.filter. fileCondition.gv implements the functionality for wrapper. Negative if the process has not exited console line the output line of the console.commandfile property.script. callCount can be used to define the required variables Example: if (callCount == 0) myVar = 0 id <n> from wrapper.script. Example: Send an email and show a system tray message if an exception is logged: 11 of 21 8/4/2011 4:07 PM .<n> state the current state of WrappedProcess. Groovy scripts are compiled and executed within the JVM of the wrapper. Whereas the controller requires rights to open a server socket and write to log files. If not.exception.conf scripts/sendMail.gv enables the application only on the active node.trigger. YAJSW will "associate" the application with the default desktop and: wrapper.sourceforge. The user is defined by the property wrapper.ntservice.args=Exception Condition Scripts Condition scripts are scripts executed cyclically.tray=scripts/trayMessage.desktop=WinSta0\\Default. and will execute the script <count> times.stop() Testing a script In order to test a script and its configuration without running an application and waiting for it to trigger: runScript.start() and when the active node of the cluster changes.timeout=300.exception.filter.tray.Introduction http://yajsw.bat -t will trigger the condition script but will not start the process. The application can be started on a different user.logon_active_session = true. You can: set your computer to automatically log-on a user on boot using a tool such as Sysinternals Autologon set in the configuration file: wrapper. that is services which open a user interface window or a system tray icon. exception found in console output please check the log file wrapper.net/ add the following properties to wrapper. OS Users YAJSW consists of 2 processes: The wrapper (controller) and the wrapped application. YAJSW exception.account the according password.exception.script.YAJSW .exception.exception.1=LanmanServer.filter. If you want to run your service without change you will need a logged on user. The configuration property wrapper.cluster. If a condition is defined the call to wrapper.app. The sample script cluster. NOTE: using this feature can expose your computer to the shatter attack security risk.ntservice. Example: runScript.filter.dependency.com.mail. It will then create a WrappedProcess.filter. The process is started and stopped within the script by calling process. not possible to run interactive services.filter.ntservice.trigger. the user is changed.bat conf/wrapper.password YAJSW checks if the current user of the controller is the application user.mail=Exception wrapper. 12 of 21 8/4/2011 4:07 PM . generally root on Linux or administrator or system on Windows.script sets a script which is called on first call to WrappedService. Windows Session0 Isolation As of Windows Vista it is. and: wrapper.exception. time for the user to log-on and for the application to startup.gv wrapper. NOTE: setting this property on none clustered nodes will crash the JVM.bat -c or wrapper. per default.script.bat <configuration file> <script> [<count>] This will search for the script and will determine its arguments in the configuration.filter.gv MSCS Cluster Aware Wrapper YAJSW may be configured to be MSCS cluster aware.mail=scripts/sendMail.conf file: wrapper.tray=Exception wrapper. but will not start it.script. the service will start after network is available. Within the script one may define actions which are executed when the active node changes. The controller should therefore be started as a privileged user.startup. Default count is 1.gv wrapper.app.script. YAJSW will wait for the user to log on and will logon the application to that user and :wrapper.start() or process.windows. is defined by wrapper. if
[email protected]
Another Java Service Wrapper . this may not be appropriate for the wrapped application. no error is logged. Per default this is the System user. Entering passwords User account names and passwords are defined in the wrapper configuration. Thus you may reduce the size of the distribution by including only libraries required for your functions. No password is required for changing the user. These are loaded when a groovy script is instatiated. In general one will use CLI for the service password and tray icon for getting the application user password if the application is supposed to run as a service. To help with this the third party libraries have been grouped into the following folders: core The minimal set of libraries required.ntservice.bat. per default.The user will have to click the respond button in the tray icon menue and enter the required data. On windows we are using the function CreateProcessAsUserW . which may be too short for java applications.1 = -Xmx5m 13 of 21 8/4/2011 4:07 PM . One may define the user and group: wrapper. This requires the SE_ASSIGNPRIMARYTOKEN_NAME and SE_INCREASE_QUOTA_NAME user rights. extensions Libraries required for extended functionalities If an extension library is missing. You may implement your own groovy scripts for this or use the available utilities: wrapper. The memory requirements of the wrapper process are relatively low and are constant. util. When the application is started as a service there is no CLI console to enter the data.inquireTryIcon('please enter password for winods service user')} util. This is available only on systems with the _POSIX_SAVED_IDS feature.net/ NOTE Windows: On MS-windows.sourceforge. This can be achieved with groovy scripting in the configuration file.inquireTryIcon(String) displays the given message on the system tray icon and waits for the user input.txt file in the according folder.ntservice.YAJSW .account=<group>\\<user> NOTE JSW: Conform with JSW wrapper.account is used only for windows services and sets the user of the controller when it runs as a service. We are not using CreateProcessWithLogonW because the command line length is limited to 1024 chars.ntservice. However for security reasons one may require that the password be entered by the user who is installing/starting the application. NOTE Linux: On Linux we use the functions setreuid and setregid. YAJSW offers 2 utilities to get user input.password.additional.inquireCLI('please enter password for winods service user')} wrapper.password = ${util.inquireCLI(String) prints the given message to the wrapper process console and waits for the user input. They may vary in case groovy scripts are used and they depend on the operating system. NOTE: groovy scripting and the implemented utilities can be used not only for passwords but for all other configuration properties.ntservice.ntservice.<n>.Introduction http://yajsw. The java options for the service are set in the configuration file with the properties wrapper.additional. if not configured otherwise services are started under the SYSTEM account. On windows the following settings are recommended: Setting in the configuration file: wrapper. A description of the libraries and corresponding functions is found in the ReadMe. If a core library is missing an error is logged.password = ${util. The password is defined by the property wrapper. However an exception will occur if the extension is missing groovy Libraries required within groovy scripts. If the password is defined in the configuration file then it is not visible in the command line of the application nor in the windows services GUI . YAJSW lib folder If you include YAJSW with your own distribution you may not require all features. Wrapper process java options The java options for the wrapper are set in the shell script setenv.app.Yet Another Java Service Wrapper .app. conf: # the groovy file to be executed wrapper.bat: Wrapping groovy scripts Here a configuration sample for wrapping groovy scripts: wrapper.action=RESTART 14 of 21 8/4/2011 4:07 PM .helloworld_groovy.file=conf/logging.OutOfMemoryError wrapper.java.dir = ${CATALINA_HOME} # classpath wrapper.java.Introduction http://yajsw.2 = bin/bootstrap.working.additional.jar -i conf/wrapper.java.java.gv # the required jar files wrapper.apache.util. However it is better to separate configuration and logic.conf rem start the service java -jar wrapper.java.2 = -Djava.net/ wrapper.dirs=endorsed wrapper.helloworld_groovy. Here will install 2 services: one for running tomcat. wrapper.config.classpath.1=lib/extended/groovy/*.displayname = groovy_helloworld_service # Description of the service wrapper.jar # additional options wrapper.java.juli.Yet Another Java Service Wrapper .1=java.ntservice.mainclass = org.util.manager=org.Bootstrap # working directory.additional.ntservice.lang. This could be a system variable or could be set in the groovy script wrapper.properties wrapper.jar -t conf/wrapper.additional.helloworld_groovy.1 = -Djava. Here an example for a groovy script to install tomcat as a service and to restart tomcat daily at 00:00 h Note that there are different way to implement this with YAJSW.java.on_exit.java.endorsed.4 = -Dcatalina.java.catalina.description = Sample groovy script Here the shell commands to install the script as a service and to start it rem install it as a service java -jar wrapper. wrapper.name = groovy_helloworld_service # Display name of the service wrapper.apache.jar wrapper.additional.logging.jar # Name of the service wrapper.startup.conf: # YAJSW: Application main class wrapper.default=RESTART #restart tomcat if out of memory wrapper.trigger.ntservice.additional.app.additional.io.home=.trigger.conf YAJSW groovified: WrapperBuilder YAJSW can be embeded in groovy scripts.tomcat.classpath.java.2 = -server Setting in the script setenv.logging.classpath.groovy=scripts/helloworld.1 = lib/*.3 = -Djava.ntservice.sourceforge.base=. the other for running a groovy script which will install/start/stop tomcat The configuration file for running tomcat: Note that we could do the complete configuration within the groovy script.6 = -Djava.YAJSW .5 = -Dcatalina.ClassLoaderLogManager wrapper. wrapper.additional.tmpdir=temp # restart tomcat if it crashes wrapper. conf" // set catalina home here if no system env var is available //builder.ntservice.tomcat.start() if (tomcatService.service() // get a process for stopping tomcat // first set the app parameter builder.Yet Another Java Service Wrapper .YAJSW .description = Tomcat The script for installing and restarting tomcat restart_tomcat.config" = "conf/wrapper."CATALINA_HOME"= // get a service for starting tomcat // first set the app parameter builder.ntservice.Introduction http://yajsw.restart_tomcat_gv.name = Tomcat # Display name of the service wrapper.conf # the groovy file to be executed wrapper.waitFor() if (tomcatStopProcess.isRunning()) println "tomcat started" Next we need a configuration file for running the above script daily at 00:00 h wrapper.displayname = Tomcat # Description of the service wrapper."wrapper.exitCode == 0) println "tomcat stopped" // check if the tomcat service is installed if (!tomcatService.ntservice.groovy=scripts/restart_tomcat.isInstalled()) tomcatService.bat stop tomcatStopProcess.sourceforge.parameter.gv # the required jar files wrapper.app.1=lib/extended/groovy/*.net/ # Name of the service wrapper.java."wrapper.1" = "stop" // now get a process tomcatStopProcess = builder.gv /* * script for restarting the tomcat service */ import org.stop() // stop tomcat: equivalent to a call to catalina.start() // wait for this process to terminate tomcatStopProcess.install() // start the service tomcatService.groovy.* // get a wrapper builder builder = new WrapperBuilder() // set the configuration file builder.app."wrapper.rzo.1" = "start" // now get a service tomcatService = builder.yajsw.jar 15 of 21 8/4/2011 4:07 PM .classpath.parameter. Introduction http://yajsw.cache=${java.ntservice. HTTPS. Example: wrapper. On the other hand we support other file systems such as local files.1=libs/mylib.* wrapper.jar -i conf/wrapper.restart_tomcat_gv.resource. Example: wrapper. Subversion.sourceforge.java.codebase=http://mysite. These files (resources) are specified with the properties wapper. ZIP. Therefore we do not implement security features such as sandbox. For more details on the supported file systems please refer to commons vfs.cache. All relative files specified in wrapper.resource.conf Further samples for running the nutch crawler.local indicates if local files should be copied to the cache.ntservice.displayname = restart_tomcat_gv # Description of the service wrapper.cron=0 0 0 * * ? At last we install the above script as a service and start it rem install it as a service java -jar wrapper. Building YAJSW The source code is included in the download. FTP. We may for example use jar files from a maven repository or from subversion. With YAJSW we however assume that we are in an enterprise environment.classpath are supposed to be relative to this root. Execute gradlew. The property wrapper. On application startup we syncrhonize the cache with the remote files by checking the file lastModified attribute.dll 16 of 21 8/4/2011 4:07 PM .codebase defines the root base.local=true NOTE: lazy download is not supported. NOTE: if no cache is defined /yajsw_cache is used as default cache folder The application may require more resources than just the classpath. All specified files are downloaded to the cache folder. Samba. All remote files are copied to this directory.<n> and are downloaded to the Example: wrapper. SMTP.tmpdir}/myapp wrapper.cache.io. nutch tomcat and nutch with solr are found in the conf and scripts folders.lib.Yet Another Java Service Wrapper .images = images/*.cache defines the path to the local cache.restart_tomcat_gv.YAJSW .name = restart_tomcat_gv # Display name of the service wrapper. for now.ntservice. SFTP. Network Launching of Applications .net/ # Name of the service wrapper.timer. Nor do we.jar -t conf/wrapper.conf rem start the service java -jar wrapper. WebDav.Experimental YAJSW offers a functionality similar to java web start allowing users to run applications which are not or not completely available on the current computer.resource or wrapper. This property is false per default. NOTE: if the folder does not exist it is created.description = script to restart tomcat # cron timer wrapper. Go to the folder <yajsw>/build/gradle.com/application-files or wrapper.START. implement features such as splash screens or desktop icons. The boolean property wrapper.resource.codebase=c:/dev The property wrapper. etc. HTTP. tmpdir}/myapp/libs Classpath files may be relative or absolute.conf On windows XP. NOTE: proxy exclusion list is currently not supported.com/test/wrapper. -i.jar -c http//mysite.classpath.YAJSW .jar -i http//mysite.{os.conf NOTE: for now only http proxy settings is supported.com/test/wrapper. -p) NOTE: currently the remote resources are downloaded only when the service is installed. -u.arch}.conf Platform specific configuration can be defined in platform specific include configuratoin files: Example: include=${os.Introduction http://yajsw. if the configuration file is a remote file create a local interpolated copy.Yet Another Java Service Wrapper .libs.conf install the application java -jar wrapper.com/conf2. Example: include = wrapper_stop.tmpdir}/myapp/lib/test. NOTE: currently the application is not started if the remote host is not accessible. Example: wrapper.1=lib/test.com/conf2.io.tmpdir}/myapp/lib2/test2.jar are downloaded to ${java.jar and ${java.com /test/wrapper.jar Configuration files may also be loaded remotely.name}. -t.x86.io.conf and http//someothersite.tmpdir}/myapp/images and ${java.conf will include the cofiguration files: http//mysite.java.proxyPort=8080 -c http//mysite. x86 YAJSW will include the following file: windows XP.conf include = http//someothersite. When the service is started the jar files from the cache are used to start the application. Example: start the application as console java -jar wrapper.conf To launch an application we proceed as follows: load the configuration file to memory. NOTE: some transport protocols. even if the files have been previously downloaded. In future other proxy settings will be supported.java.jar warpper.net/ are downloaded to: ${java.conf Within a conf file include files are absolute or relative. To check for a new version of the application you will have to reinstall the service. Relative locations are assumed relative to the parent configuration file.libs.com/test/wrapper_stop.sourceforge. such as webdav or ftp support folder listing and therefore also support wild cards for classpath files.classpath.proxyHost=<myproxy> -Dhttp.io. 17 of 21 8/4/2011 4:07 PM .2=http://someothersite.com/lib2/test2. NOTE: setting http proxy: java -jar wrapper. in which all includes have been resolved copy files to the cache if these are not in the cache or have different lastModified property execute the wrapper command (-c.jar -Dhttp.io. the draw application requires the file javaws. The configuration file is http://eprognos. Wrapping JNLP . j2se. convert it to a wrapper configuration file save the file to the cache and install a service which will use the configuration file to launch the application.. information If you require one of these features please post a message on the project forum or tracker. which is not defined in draw. If you have suggestions or further requirements on how to integrate the wrapper functionality with remote launching.tomcat.jnlp will parse the jnlp file. please post your ideas on the project forum.jnlp will parse the jnlp file.com/webdav/wrapper.com/javase/technologies/desktop/javawebstart/apps/draw. lazy.sourceforge. <jar . Java Web Start Support . This will invoke a jar file which will download YAJSW and will call either runConsole or installService. This will wrap a tomcat which is installed on my test server (eprognos. component-desc. However. extension. main-class>.Currently only for windows Installing the same service on multiple servers is a pain.jar -i http://java. is provided to test this feature. installer-desc. YAJSW may help by providing a java webstart bootstrap. java -jar wrapper.jar. arch.javaws.jnlp Currently only "simple" jnlp configurations are supported. convert it to a wrapper configuration file and will launch the application as described in Network Launching. Vista & co: you will need to run your browser as administrator (right click -> run as administrator) in order to be able to 18 of 21 8/4/2011 4:07 PM . This is achieved by adding some local configuration as follows: java -jar wrapper.jar -c http://java. The following jnlp tags/attributes are NOT supported: External jnlp OS. NOTE: -d <remote file> is supported.Experimental . The following live demo will download YAJSW which will download and start a tomcat server Note: for windows 7.com/javase/technologies/desktop/javawebstart/apps/draw. remoteLauchTomcatDemo.sun.sun.bat.jar -c -d conf/wrapper.conf This is a new feature.conf http://java.sun.Yet Another Java Service Wrapper .YAJSW . locale depdent configuration Applets package.Experimental A call to java -jar wrapper.net/ NOTE: A batch script.Introduction http://yajsw.com) and will start it localy on port 8081.jnlp. part. nativelib.com/javase/technologies/desktop/javawebstart/apps/draw. Managing services on multiple servers in a multi-platform environment may be cumbersome. For this function the following files are required: wrapper.t.Introduction http://yajsw.jnlp : please set the following arguments: <argument>path-to-yajsw-folder-on-the-server</argument> <argument>destination-folder-on-local-computer</argument> <argument>yajsw-command (c.jar this is the file which is executed by java web start.Yet Another Java Service Wrapper .sourceforge. You may decide to sign it with your credentionals. The keystore and batch files for signing are found in the build folder remote-configuration-of-application this file is the file used to remotely sart the applicaition as described here. In a future release this feature will be used to drive yajsw tests on multiple platforms. If a gui is enabeled you may leave certain arguments empty and have the user enter them.i.Experimental .net/ start/install services.YAJSW .Currently only for windows This new feature is currently implemented for windows only. The YAJSW Services Manager allows one to : 19 of 21 8/4/2011 4:07 PM .y)</argument> <argument>remote-configuration-of-application</argument> <argument>nogui</argument> (optional) If you do not want yajsw to display a gui add nogui as last argument. wrapperWS. The file has been signed as described here. Services Manager . If you would like to have this feature for other frameworks please post on the project forum. experimental This android app allows one to monitor services and daemons on multiple servers on an android mobile phone. Click "<<" to remove them from the services table.Introduction http://yajsw. In future releases further functions will be implemented. To maintain an overview of the services you are interested in: select the services you do not want to see and click "<<" to hide them. And removed using the "-" file. Jboss Netty : TCP/IP inter-process communication is done using jboss netty. but not the application. Third party Libraries Commons Configuration: Configuration is done using commons configuration. YELLOW: YAJSW wrapper is running. Currently the app implements 2 views: List of hosts : RED no connection to the Services Manager Server on the host. To run/install the server use the according scripts in the <yajsw>/bat folder To start the user interface use the script under <yajsw>/bat folder. Feedback is welcome. JNA : The complete implementation is thus in java instead of C and will be available on all platforms for which JNA will be available.sourceforge. All settings are saved in the "ServiceManager. Select the console application and click the "reload Console App" button.exe on windows Joda: for easier handling of time and date (used in timeCondition. This makes the implementation of the communication readable and easily adaptable.YAJSW . To add them to the services list click ">>".ser" file. The services manager consists of a server and a client process. You may also start the server and client using java web start: start server using java web start start client using java web start NOTE: the client server communication is implemented through asynchronous hessian rpc.gv) Launch4j : for generating wrapper. The server process must be running on all managed hosts.gv) Tango Icon Library: Icons for the system tray icon SNMP4J: for sending snmp traps (in snmpTrap. thus allowing a richer and more flexible configuration. This will hopefully be integrated in the jboss netty project. To install click install enter the path to a YAJSW configuration select the hosts and click install. YAJSW additionaly supports OS environment variables and java system properties. Swipe the screen to change the view. The android application connects to a single server process called the ServiceManagerHub. using multicast discovery. retrieves the data and displays it on the smartphone. the according wrapper must be running. The hub server. GREEN host is connected List of services: RED: service is not running. To update YAJSW console applications. connects to the Services Manager Server processes in the network.gv) famfamfam : icons Abeille : Gui forms designer JGoodies FormLayout : Layout used by abeille Apache Velocity : java template engine Commons VFS : Virtual File System for downloading files in network launching 20 of 21 8/4/2011 4:07 PM . Android Services Manager . JavaMail : used for sending emails (in sendMail. Start/Stop services and YAJSW console processes: Select one or more services and click start/stop Install/Uninstall YAJSW services: Select one or more services and click uninstall.Yet Another Java Service Wrapper . GREEN: service is running.net/ View services and YAJSW console processes on multiple hosts: Select one or multiple hosts and click ">>" to view their services. The android application connects to the hub process. Hosts are add using the "+" button. as an alternative for filter matching Groovy : for scripts. Quatrz : Job scheduling JREXX : High Performance regular expression matching. Commons CLI 2 : Command Line Interface can thus be easily extended. sourceforge. Gradle: A build tool alternative to maven. ant & co.Ron 21 of 21 8/4/2011 4:07 PM .Yet Another Java Service Wrapper .YAJSW . .Introduction http://yajsw.net/ testNG unit test framework used with groovy jMock mock objects framework for unit tests GlazedLists: GUI grid framework used in ServiceManagerClient Hessian: Hessian is a compact binary protocol for connecting web services. Documents Similar To YAJSW - Yet Another Java Service Wrapper - IntroductionSkip carouselcarousel previouscarousel nextAutosys Good OneOSM_SRS_v0.5c_finalException Handling on NXTStarting a Server Using UnixManualSchellingTutorialCisco ACSCar Ma CookbookRbsirules-101--08--classesCiscoIOU HowtoGeoExt Workshoppostgis-article1New Microsoft Office Word DocumentYet Another Insignificant Programming NotesUnix Programmers ManualModelsim Tutorial UgFree ColpstoolsCOMMANDS San Switch Cheat Sheeti Python3D Matlab Model User ManualSolaris Advanced User Guide97_SQLPlus Getting Started for WindowsSL500Hog II III Thesaurusrevisions.txtCli Scripts Whitepaper 1.03sg246013More From Gottipati Sree HarshaSkip carouselcarousel previouscarousel nextSepharial New Dictionary of AstrologySepharial - Astrology and MarriageVedic_MathsHarsh ABest Books About Computing PlatformsUpgrading and Fixing Computers Do-it-Yourself For Dummiesby Andy RathboneTroubleshooting and Maintaining Your PC All-in-One For Dummiesby Dan GookinLaptops For Dummiesby Dan GookinWindows 10: 101 Tips & Tricksby Jonathan MoellerJava : Complete First Time Beginner's Reference for the Really Impatient.by Harry. H. Chaudhary.Windows Server 2016 Cookbookby Jordan KrauseFooter MenuBack To TopAboutAbout ScribdPressOur blogJoin our team!Contact UsJoin todayInvite FriendsGiftsLegalTermsPrivacyCopyrightSupportHelp / FAQAccessibilityPurchase helpAdChoicesPublishersSocial MediaCopyright © 2018 Scribd Inc. .Browse Books.Site Directory.Site Language: English中文EspañolالعربيةPortuguês日本語DeutschFrançaisTurkceРусский языкTiếng việtJęzyk polskiBahasa indonesiaSign up to vote on this titleUsefulNot usefulYou're Reading a Free PreviewDownloadClose DialogAre you sure?This action might not be possible to undo. Are you sure you want to continue?CANCELOK
Report "YAJSW - Yet Another Java Service Wrapper - Introduction"
×
Please fill this form, we will try to respond as soon as possible.
Your name
Email
Reason
-Select Reason-
Pornographic
Defamatory
Illegal/Unlawful
Spam
Other Terms Of Service Violation
File a copyright complaint
Description
Copyright © 2024 DOKUMEN.SITE Inc.