Deployment
This section describes how to deploy a Wisdom application on a server. Wisdom is particularly easy to deploy as it’s almost self-contained. The only requirements are:
-
a Java 7+ virtual machine
-
a writable disk space
Packaging a distribution
To build a distribution of your application just use: mvn clean package. A distribution containing the Wisdom
runtime, the application dependencies and external assets are created in the target folder as a zip file. Wisdom
application deployment is based on this distribution file.
Launching & Stopping
First, unzip the distribution file anywhere. Be aware that the zip file does not include a base directory. To launch
a Wisdom application in background, just use the chameleon.sh script provided at the root of the unzipped location:
./chameleon.sh start
Stopping is quite similar:
./chameleon.sh stop
|
Note
|
Why chameleon.sh? Actually, Wisdom is built on top of the OW2 Chameleon project,
packaging a set of OSGi bundles and providing low-level features, such as logging, dynamic deployment…
|
To avoid the output on the console, use:
./chameleon.sh start > /dev/null
|
Note
|
The server’s process id is written to the RUNNING_PID file. To kill a running Wisdom server,
it is enough to send a SIGTERM to the process to properly shutdown the application.
|
|
Note
|
the HTTP port can be set by configuring the JVM_ARGS system variable before launching the application:
export JVM_ARGS="-Dhttp.port=9005" && ./chameleon.sh start
|
Accessing logs
By default the logged messages are written in logs/wisdom.log.
Production deployment
Specifying the HTTP server address and port
You can provide both the HTTP port and address from the JVM_ARGS system variable. The default is to listen on port
9000 at the 0.0.0.0 address (all addresses).
export JVM_ARGS="-Dhttp.port=8080 -Dhttp.address=127.0.0.1"
./chameleon.sh start
|
Note
|
Note that these configurations are only provided for the default embedded Netty server. |
You can configure the HTTPS port using the https.port property.
You can disable HTTP or HTTPS using the -1 value. The 0 value enables a free port lookup.
|
Tip
|
The free port lookup does not rely on the port 0 hack, but actually attempts to bind on random ports. |
Specifying additional JVM arguments
You can specify any JVM arguments to the JVM_ARGS system variable. Otherwise the default JVM settings will be used:
export JVM_ARGS="-Xms128M -Xmx512m -server"
./chameleon.sh start
Specifying alternative configuration files
The default is to load the conf/application.conf file. You can specify an alternative configuration file if needed:
export JVM_ARGS="-Dapplication.configuration=conf/application-prod.conf"
./chameleon.sh start
Wisdom application as a system service
This section explains how to create a system service starting and stopping your application when the machine boots and shutsdown.
|
Note
|
This section explains the configuration for CentOS, however the same idea can be applied for other systems such as Ubuntu |
The service script used to manage a Wisdom application is very basic and relies on the chameleon.sh script. In
addition, most of the configuration is similar to most Wisdom applications. This script can be downloaded from
here.
In this script, you must configure some variables:
WISDOM_HOME=/home/wisdom/wisdom => The path of the wisdom application
APPLICATION_MODE="PROD" => The execution mode
export JVM_ARGS="-Dapplication.mode=${APPLICATION_MODE}" => Add the other variables at the end of this line
JAVA_HOME=/usr/java/latest/ => The Java location
USER=wisdom => The user executing the application
|
Warning
|
The set user must be able to write in the application directory. |
Once edited, copy the script file to /etc/init.d. Then add the execution flag with chmod +x /etc/init
.d/filename. Add the script to the boot and shutdown sequence using: chkconfig --add /etc/init.d/filename. Finally,
enable the configuration with chkconfig filename on. So, if your file is named wisdom,
the sequence of instructions is the following:
cp wisdom.sh /etc/init.d/wisdom chmod +x /etc/init.d/wisdom chkconfig --add /etc/init.d/wisdom chkconfig wisdom on
Once done, start the service using /etc/init.d/wisdom start. The service can be stopped using /etc/init.d/wisdom/stop.