Active Profiles
Active profiles allow you to adjust the behaviour of the site based on where it is deployed. Perhaps you need different configuration, such as SMTP server, for different environments, or you want to enabled debug or service stub behaviour in development environments.
Enabling an active profile
Active profiles can be enabled on the JVM with the bemoko.activeProfiles system property, e.g.
-Dbemoko.activeProfiles=dev
You can specify multiple profiles, e.g.
-Dbemoko.activeProfiles=dev,europe
Active profile can be configured in the live-config.xml file as well, e.g.
<live>
<activeProfiles>prod</activeProfiles>
</live>
Driving behaviour based on which active profiles are enabled
You can test whether a given active profile is enabled in an expression with profile.NAME where NAME is the name of your active profile, e.g.
<config>
<!--
Only enable production configuration if activeProfile "prod" is enabled
-->
<source file="prod.cfg" expr="profile.prod"/>
</config>
You can also drive active profile specific behaviour in plugins, e.g.:
if (Bemoko.profile.prod) {
...
}
... and in templates, e.g.:
[#if profile.dev]
<h1>Development mode</h1>
[/#if]
Standard Profiles
bemoko uses the following standard profiles, although you are free to extend as you see fit:
| Profile name | Description | JVM configuration |
|---|---|---|
| dev | Development servers | -Dbemoko.activeProfiles=dev |
| ||
| stage | Testing servers | -Dbemoko.activeProfiles=stage |
| ||
| performance | Performance tuned | -Dbemoko.activeProfiles=performance |
| ||
| prod | Production servers | -Dbemoko.activeProfiles=prod |
| ||
For examples addons are typically configured for debug logging to be disabled in development, i.e. when profile is set to "dev".
To enable your system for production set "prod" active profile on the JVM arguments:
-Dbemoko.activeProfiles=prod
bemoko Best Practice
At bemoko we often have multiple environments from which we serve a single site. We set the following activeProfiles for each of these environments.
| ActiveProfile name | Description |
|---|---|
| (no setting) | Zero configuration development machine |
| developerName,dev | Personal configuration development machine (only required if you want to differentiate yourself from the default development settings. For example "dev,ian" for Ian's dev machine. |
| environmentName,dev | Development server in a given environment. For example "dev,bemoko" is our development bemoko environment |
| environmentName,stage,performance | Stage server in a given environment configure in a performance optimised mode. For example "stage,bemoko,performance" is our stage bemoko environment |
| environmentName,prod | Production server in a given environment. For example "prod,bemoko" is our production bemoko environment |
Following this configuration from the outset gives you total control as to how to you target configuration to each environment, for example when using feature toggles.