-
-
Notifications
You must be signed in to change notification settings - Fork 605
Running apache tomcat
OSv has now support for combining modules into an executable image. There are a couple of pre-configured modules available for OSv already. They reside in osv-apps repo, which is currently added as a submodule to osv.git under apps/
directory.
The definition for tomcat module is under apps/tomcat
. Module definition has several components:
-
Makefile
- is called by OSv'smake
. It should fetch all the necessary files. Currently it downloads and extracts tomcat bundle from apache site. And applies some basic configuration changes. -
module.py
- holds (java) run configurations. -
usr.manifest
- declares which files should be copied into the image file system
You can adjust the configuration as needed.
Modules can be combined during image build. There is a default image configuration which pulls tomcat module, it's under images/tomcat.py
in osv.git.
To build the image just run:
make image=tomcat
The image will be in build/release/usr.img
To run it just execute:
sudo scripts/run.py -nv
The -nv
options enable networking. sudo
is needed to configure network interfaces.
If you already have one you can skip this step.
- Download core binary package, eg: http://ftp.ps.pl/pub/apache/tomcat/tomcat-7/v7.0.47/bin/apache-tomcat-7.0.47.tar.gz
- Extract it, eg to
~/bin/apache-tomcat-7.0.47
- [Optional] Configure it
You need to put the package under /usr/tomcat
in the guest file system. For development you can leverage make
process to do so:
- Append the following line to
usr.manifest.template
replacing/home/tgrabiec/bin/
with the directory in which your tomcat package is located in the host:
/usr/tomcat/**:/home/tgrabiec/bin/apache-tomcat-7.0.47/**
- run
make
. On incremental build you will need to removebuild/release/usr.img.d
before or it will complain about inability to build dependencies.
If you already have the image, you can start OSv and use scp
to copy the package.
Save the following script as tomcat-cmd-line.sh
. It will be used to build the command line for starting tomcat.
#!/usr/bin/env bash
CATALINA_BASE=/usr/tomcat
CATALINA_HOME=$CATALINA_BASE
CLASSPATH=$CATALINA_HOME/bin/bootstrap.jar
# Logging
LOGGING_CONFIG="-Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties"
LOGGING_MANAGER="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
CLASSPATH=$CLASSPATH:$CATALINA_HOME/bin/tomcat-juli.jar
CATALINA_TMPDIR=$CATALINA_BASE/temp
echo "java.so $JAVA_OPTS -cp $CLASSPATH \
$LOGGING_CONFIG \
$LOGGING_MANAGER \
$CATALINA_OPTS \
-Dcatalina.base=$CATALINA_BASE \
-Dcatalina.home=$CATALINA_HOME \
-Djava.io.tmpdir=$CATALINA_TMPDIR \
org.apache.catalina.startup.Bootstrap start"
You can now start OSv:
sudo scripts/run.py -nv -e "`./tomcat-cmd-line.sh`"