|
|
 |
|
|  |
 |
 |
 |
| Launching Your Application (Linux / UNIX) |
Launching Your Application (Linux / UNIX)
 |
|
|
 |
 |
 |
|
The Wrapper is shipped with a sh
script which can be used to reliably start and stop any Java
application controlled by the Java Service Wrapper.
First copy the sh script to the
bin directory of your
application.
{WRAPPER_HOME}\src\bin\sh.script.in
|
Rename the script file to reflect the name of the application.
Now open the script into an editor. We need to set the long and
short names to reflect that the script is being used to launch
your application. You will see two variables immediately after
the header of the script. APP_NAME
and APP_LONG_NAME. Note that
the default values of both of these variables are
Ant friendly
tokens which can easily be replaced as part of a build.
Suggested values for these variables are shown below.
APP_NAME="myapp"
APP_LONG_NAME="My Application"
|
The script should not require any additional modification.
However it does assume that it is placed into the same directory
as the wrapper executable.
It also assumes that the wrapper.conf
file will be located within a
conf directory one level up,
../conf/wrapper.conf. If
you wish to locate this file someplace else, then that can also
be set using the WRAPPER_CONF
variable in the script.
|
NOTE
|  |
Important! Before proceeding, please make sure that both
the script and the wrapper
executable have their executable bit set.
|
|
NOTE
|  |
The sh script will attempt to
create a pid file in the /var/run.
If the user used to launch the Wrapper does not have permission to
write to this directory then this will result in an error. An
alternative that will work in most cases is to write the pid file
to the same directory where the wrapper executable is located. To
make this change, edit the sh
script and change the following line:
to:
|
|
 |
 |
|
The application can now be run by simply executing
bin/myapp console.
Because of the way the Wrapper script sets its current directory,
it is not necessary to run this script from within the
bin directory.
/usr/lib/myapp/bin/myapp console
Running My Application...
wrapper | --> Wrapper Started as Console
wrapper | Launching a JVM...
jvm 1 | Wrapper (Version 3.x.x)
jvm 1 |
|
When running using the console
command, output from the JVM will be visible in the console.
The application can be terminated by hitting CTRL-C in the command
window. This will cause the Wrapper to shut down the application
cleanly.
As you will see if you omit a command, the scripts shipped
with the wrapper are fairly standard daemon scripts. They
accept console,
start,
stop,
restart,
status, and
dump commands.
The start,
stop, and
restart commands are common
to most daemon scripts and are used to control the wrapper and
its application as a daemon process. The
status command
can be used to find out whether or not the wrapper is currently
running. The console command
will launch the wrapper in the current shell, making it
possible to kill the application with CTRL-C. The final
command, dump, will send a
kill -3 signal to the wrapper
causing the its JVM to do a full thread dump.
|
 |
 |
|
The application can be run as a detatched daemon process by
executing the script using the start
command.
/usr/lib/myapp/bin/myapp start
Running My Application...
|
When running using the start
command, output from the JVM will only be visible by viewing the
wrapper.log file using
tail -f wrapper.log
Because the application is running as a detatched process, it can
not be terminated using CTRL-C and will continue to run even if
the console is closed.
To stop the application rerun the script using the
stop command.
/usr/lib/myapp/bin/myapp stop
Stopping Test Wrapper Sample Application...
Stopped Test Wrapper Sample Application.
|
|
 |
 |
|
Installing the application to start up when the system boots and
shutdown when the system shutsdown is platform specific. I have
tried to include instructions for platforms which I have access
to. If your platform is not included, please read over those that
have been included and adapt as necessary. Please post what you
come up with to the
wrapper-user@sourceforge.net
mailing list and I will be more than happy to include them in the
next release.
|
 |
 |
|
As an alternative to using the scripts provided with the Java Service
Wrapper. You may choose to launch the Wrapper directly. If the
wrapper executable is launched
without any parameters, the following usage output will be displayed.
/usr/lib/myapp/bin/wrapper
Wrapper (Version 3.n.n) http://wrapper.tanukisoftware.org
Usage:
wrapper <command> <configuration file> [configuration properties] [...]
wrapper <configuration file> [configuration properties] [...]
(<command> implicitly '-c')
wrapper <command>
(<configuration file> implicitly 'wrapper.conf')
wrapper
(<command> implicitly '-c' and <configuration file> 'wrapper.conf')
where <command> can be one of:
-c --console run as a Console application
-? --help print this help message
<configuration file> is the wrapper.conf to use. Name must be absolute or relative
to the location of wrapper
[configuration properties] are configuration name-value pairs which override values
in wrapper.conf. For example:
wrapper.debug=true
|
To run the Java Service Wrapper in a shell, you would
specify the -c command, followed
by the wrapper.conf file. The location of the
wrapper.conf file can be an
absolute or relative location. If a relative path is used, the path
is always relative to the location of the
wrapper file, not the current
directory.
/usr/lib/myapp/bin/wrapper -c ..\conf\wrapper.conf
|
To launch the application a daemon process (Using the shell
script is recommended):
/usr/lib/myapp/bin/wrapper -c ..\conf\wrapper.conf wrapper.daemonize=TRUE
|
|
|
|
|
| |
 | If you notice something that is incorrect, missing, or simply feel that some part of this page could be explained better, feel free to log in and add a comment. You will need to register before you can log on. |
|
|  |
|
 |
|