ChimeraConfig
Chimera is configured by properties in the file config.properties
in the main folder. It specifies the credentials for your database, the URL of the event processing platform to use, your email server credentials, and some more. This file is copied by maven from src/main/resources/config_template.properties
if it does not exist in the main folder. This will happen for the first build, and whenever the file is deleted. While copying, maven also applies filtering, i.e. it replaces variables, e.g. ${db.schema}
by their values, which are either provided as command line parameter to maven (-Ddb.schema=chimeradb
) or default values taken from the pom.xml.
Configuration happens during build time: the (adapted) config file is packaged into the war file. Therefore, a changed configuration requires to re-built and re-deploy the Chimera engine.
The following example builds Chimera and configures it with the default values. In most cases, just the username and password need to be provided.
mvn install -Ddb.user=chimera -Ddb.password=bp2015 -Ddb.schema=chimeradb -Ddb.url=jdbc:mysql://localhost:3306/chimeradb -Ddb.test.schema=chimeradb_test -Ddb.test.url=jdbc:mysql://localhost:3306/chimeradb_test
log4j.properties
contains the logging properties, i.e. to what file the logs should be written, and what and how log entries are displayed. Per default Chimera logs to chimera.log
in the tomcat logs directory (e.g. /usr/local/apache-tomcat-7.0.XX/logs
).
The database schema is defined by the files src/main/resources/JEngineV2_schema.sql
resp. src/main/resources/JEngineV2_schema_jenkins.sql
. If there is an updated schema.version
property in the pom.xml the database schema is dropped and created by one of the files.
TODO: Difference between those two sql files
The situation is different when deploying Chimera to a remote machine, e.g. the development server 113.These builds are performed by the Jenkins CI system using the remote profile and parameters for the maven build.
Because multiple instances of the Chimera instance can run on one server, e.g. one instance for the dev branch and another for the master branch, each instance has to use its own database. To this end Jenkins appends the $JOB_NAME to the schema name when creating a database on the remote server (or checking whether it exists).
The file src/main/resources/config_template.properties
contains
placeholders / variables that are replaced during the maven build
process with the values of that variables. Jenkins provides these
parameters to the Maven call with the right values for the remote server
the engine is deployed to.
The pom.xml defines a profile remote
which is used by the Jenkins job
ChimeraDev
that deploys the Chimera engine onto the development server
113. This profile configures the maven-ant-plugin to rename the file
target/classes/config_template.properties to
target/classes/config.properties before packaging (i.e. the process of
generating the war file). At this time the variables have already been
filtered by maven, i.e. the properties in the file have the correct
values.
You can read more about build profiles here: https://maven.apache.org/guides/introduction/introduction-to-profiles.html
Jenkins manages a settings file that can be used in maven builds. This file contains credentials and the deploy path for tomcat.
The dev
branch is automatically build by Jenkins and deployed to a docker container accesible at https://bpt-lab.org/chimera-dev. The Chimera instance is configured using the file config.properties.tpl
. Because the property values heavily depend on the URL and path to which Chimera is deployed, the config.properties.tpl
uses environment variables (e.g. $UNICORN_URL
). These environement variables are set when deploying the image.
The Dockerfile
builds an image based on tomcat7 and copies the required resources (e.g. the Chimera.war
, config.properties.tpl
, etc.). The CMD
command at the end of Dockerfile
specifies that the docker_deploy.sh
script is executed, when the image is run. Not at build time, but rather when executing docker run bptlab/chimera:dev
to start a container. This script replaces the environment variables with their values, that have to be provided to docker run
. Therefore, the full command used to run the image is:
docker run -d --name 'chimera-dev'
-e CHIMERA_URL=https://bpt-lab.org -e CHIMERA_DEPLOY_NAME=/chimera-dev
-e CHIMERA_DB_NAME=Chimera_DB -e CHIMERA_DB_USERNAME=chimera -e CHIMERA_DB_PASSWORD=mySecret
-e CHIMERA_DB_HOST=mysql -e CHIMERA_DB_PORT=3306
-e UNICORN_URL=https://bpt-lab.org -e UNICORN_DEPLOY_PATH=/UnicornDev
bptlab/chimera:dev
The docker_deploy.sh
script in the image now knows the values of the environment variables and configures config.properties
as well as persistence.xml
correctly.