Documentation

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 nameDescriptionJVM configuration
devDevelopment servers-Dbemoko.activeProfiles=dev
 
  • dev report displayed to screen when an error occurs
  • caching enabled such that changes are picked up without a cache flush
stageTesting servers-Dbemoko.activeProfiles=stage
 
  • same as dev profile
performancePerformance tuned-Dbemoko.activeProfiles=performance
 
  • all caches enabled - explicit cache flush is required if underlying site is updated
  • dev report does not appear on the screen
  • templating errors are not displayed on the screen
prodProduction servers-Dbemoko.activeProfiles=prod
 
  • same as performance profile

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 nameDescription
(no setting)Zero configuration development machine
developerName,devPersonal 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,devDevelopment server in a given environment. For example "dev,bemoko" is our development bemoko environment
environmentName,stage,performanceStage server in a given environment configure in a performance optimised mode. For example "stage,bemoko,performance" is our stage bemoko environment
environmentName,prodProduction 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.


More