Skip to content

Configuring Martini Application Properties

Many applications deliberately expose configuration files to users, empowering them to fine-tune and customize the application's behavior at runtime. In Martini, the <martini-home>/conf/properties/application.properties file serves this purpose. Within this file, we define what are known as application properties (sometimes referred to as instance properties), which Martini utilizes during startup or runtime to configure its behavior and guide the operation of its components.

Application properties are invaluable as they facilitate the externalization of Martini's configuration, enabling Martini to operate seamlessly across various modes and environments with minimal effort.

Different Types of Properties in Martini

Override Properties

To simplify the management of configuration changes and streamline the upgrade process, Martini offers an override file feature which is located under <martini-home>/data/override.properties. This functionality allows users to preserve the original configuration stored in application.properties while selectively overriding specific properties. Restoring properties to their default state is as straightforward as removing them from the override file.

Note: It is a best practice to configure the override.properties file rather than directly editing the application.properties file.

Package-local Properties

In addition to global application properties, Martini supports properties that are localized to specific packages. These package-specific properties function similarly to Martini's global properties but have a narrower scope confined to individual packages.

Note: The properties file are not automatically generated when you create a package. If the .properties file are missing, you can create them under the conf/properties folder

Flexible Environment-specific Properties

Leveraging packages, Martini accommodates multiple .properties files tailored for distinct environments (e.g., development or production). Users can create these properties file inside conf/properties folder. This flexibility allows users to seamlessly switch between environment-specific configurations by setting the {prefix}.package.properties instance property accordingly inside the <martini-home>/data/override.properties file.

Example:

1
2
3
4
5
6
├── martini-home
│   ├── data
│   │   └── override.properties
│   │       └── develop.package.properties
│   |...
|...

Property Configuration Hierarchy

1
{prefix}.package.properties -> package.properties -> application override properties -> application.properties -> System properties -> Environment properties

This hierarchy illustrates the sequence in which properties files are processed within Martini. Properties defined at higher levels take precedence over those at lower levels, meaning that those defined earlier in the sequence are executed first. It's important for system administrators and developers to understand this hierarchy when configuring Martini instances.

Potential Restart Requirements

It's important to note that modifications made to the application.properties file may not take immediate effect without restarting Martini or reloading properties via the UI. As a best practice, consider restarting Martini whenever making widespread changes to application properties.

Editing Application Properties

There are several ways to modify an instance's application properties:

  • Using the CLI tool
  • Using the REST API
  • Using the Martini Runtime Admin UI
  • Directly editing the application.properties file via the file system located inside <martini-home>/conf/properties/application.properties

    Note: The mount for the location of this file should be external if the file system for your virtual server or Docker container is ephemeral.

Via the RESTful API

Martini provides RESTful endpoints for maintaining and configuring application properties. This API allows you to remotely do things such as:

  • Retrieve application properties
  • Add, remove, or update application properties
  • Reload application properties

Via the Martini Runtime Admin UI

To open the application.properties file in the Martini Runtime Admin UI, hover your cursor over the Server Admin menu and then select Application Properties from the sub-menu that appears. You will then be redirected to a page where you can edit the file in the editor.

Example: Configuring Consul Cluster Consider the consul.url instance property as an example. This property determines whether Martini will be included inside the Consul cluster. Whether it is for the leadership election or membership (via its URL).