5.2. Configuration management

These sub-commands can reload the running configuration (including its Halon script) and control the built-in blue-green testing that we call “live stage”. See the configuration section for more information.

5.2.1. Script syntax and packing

The script is normally edited as individual files using the Visual Studio Code integration or simply a text editor. Those are then checked and “packed” into an actual configuration file by the halonconfig script as described in the script directive section.

Given that the folder test contains halonconfig’s standard file structure (see /opt/halon/share/examples) you can pack, validate and reload the configuration directly on the MTA by:

$ cd test
(editing configuration files)
$ halonconfig
# cp dist/* /etc/halon/
# service halon reload

If you want to exclude any files inside the src/files folder from being packed you can add a .halonignore file which supports regular glob patterns.

The halonconfig command may also be used to “unpack” the configuration, reversing the described process above.

5.2.2. Reloading configurations

You can also invoke the individual reload commands directly:

$ halonctl config reload                   # /etc/halon/smtpd-app.yaml
$ halonctl queue policy reload             # /etc/halon/smtpd-policy.yaml
$ halonctl queue suspend reload            # /etc/halon/smtpd-suspend.yaml
$ halonctl queue delivery reload           # /etc/halon/smtpd-delivery.yaml

5.2.3. Blue-green testing

Halon has built-in blue-green testing, which allows you to deploy a parallel running configuration for only a selection of the traffic, for example connections from certain IP addresses or a certain percentage chosen by random. The following example will deploy a parallel configuration for 10% of connecting clients during one hour:

$ halonctl config livestage start --id t1 --file dist/smtpd-app.yaml --probability 0.1 --time 3600
$ halonctl config livestage status
t1: 2 connections(s), 30/3600 runtime
$ halonctl config livestage cancel

5.2.4. Remote configuration

The halonconfig script can be used to pack and validate configuration folders on any computer that runs Python. You can copy it from the MTA:

$ python -m venv env
$ source env/bin/activate
$ pip install pyyaml
$ pip install jsonschema
$ scp mta:/opt/halon/bin/halonconfig .
$ scp mta:/opt/halon/share/json-schemas json

and run it by specifying the JSON schema path and disabling the script linter:

$ python halonconfig --schema-dir json --no-check-hsl

You can start a live stage directly from a remote computer by using SSH stdin redirection:

$ cat dist/smtpd-app.yaml | ssh mta "halonctl config livestage start --file /dev/stdin --id t2"
$ ssh mta "halonctl config livestage status"
t2: 2 connections(s), 3 runtime