<a id="startup-configuration"></a>

# Startup configuration

This is the non-reloadable part of the configuration.
By default, *smtpd* loads it from  */etc/halon/smtpd.yaml*.
It is described by, and can be validated with, the
[smtpd.schema.json](http://lbovet.github.io/docson/index.html#https://docs.halon.io/json-schemas/6.12-stable/smtpd.schema.json).

It most importantly contains the server listen sockets (bind addresses and ports),
PROXY protocol and thread settings.

> **Note**
> 
> The example configuration in  */opt/halon/share/examples/* that is usually copied
> to  */etc/halon/* during installation contains reasonable defaults.
> Normally you only need to modify it when adding additional virtual servers,
> or changing performance related settings such as the number of threads or
> open files resource limit.

<a id="server-directives"></a>

## Server directives

The virtual [`servers[]`](config_smtpd.html.md#confval-servers) are configured in the [running configuration](config_smtpd.html.md),
but which port(s) and address(es) to listen to needs to be specified in this file.

Most of the properties applies to servers of both `smtp`, `http`, `https` and `plugin` type, therefor the only which applies to either are explicitly mentioned.

Below is an example for adding a virtual server called “relay”, listening to any IP on port 587:

```yaml
servers:
  - id: relay
    listeners:
      - port: 587
```

<a id="confval-servers-.id"></a>

### servers[].id

The id of the server. It must match the same type as configured in the [running configuration](config_smtpd.html.md).

<a id="confval-servers-.type"></a>

### servers[].type

The type of the server, a server can either be an `smtp` server, an `http` / `https` [submission endpoint](http_submission.html.md) or `plugin` [inject plugin](plugins_native.html.md#inject-plugin). The default is `smtp`.
The `https` server type requires a *servers[].tls.certs.cert* to be configured in the [running configuration](config_smtpd.html.md).

<a id="confval-servers-.listeners"></a>

### servers[].listeners[]

<sub>Only one listener is supported for servers of type http. Not supported for type plugin</sub>

Each virtual server must have one or more listen directives,
which specify which TCP port and address to listen on.

<a id="confval-servers-.listeners-.port"></a>

### servers[].listeners[].port

Which TCP port to listen on. Required.

<a id="confval-servers-.listeners-.address"></a>

### servers[].listeners[].address

IPv4 or IPv6 address to listen on.
The default is to listen to all IPv4 and IPv6 addresses.

<a id="confval-servers-.listeners-.backlog"></a>

### servers[].listeners[].backlog

The kernel connection backlog. The default is the system default.

<a id="confval-servers-.listeners-.id"></a>

### servers[].listeners[].id

An optional ID that can be used for referencing a listen directive from the
running configuration so that for example implicit TLS
can be enabled on a per-listener basis using [`servers[].tls.implicit`](config_smtpd.html.md#confval-servers-.tls.implicit).

<a id="confval-servers-.proxyprotocol"></a>

### servers[].proxyprotocol[]

<sub>Only applies to smtp servers</sub>

A list of IP addresses or networks to allow the PROXY protocol (v1 and v2) from.
Set it to *true* to allow it from all IP addresses.

<a id="confval-servers-.threads.event"></a>

### servers[].threads.event

<sub>Not supported for type plugin</sub>

The number of [`servers[]`](config_smtpd.html.md#confval-servers) event loop threads, allowing the event loop to take advantage of multiple CPUs.
If given as a number (and not an object with an ID), a event thread pool will be created named after the [`servers[].id`](#confval-servers-.id) (prefixed with an underscore).
The default is 4. If configured as an object you may  specify an id of a [`servers[].threads.event.id`](#confval-servers-.threads.event.id) or
an object with [`servers[].threads.event.count`](#confval-servers-.threads.event.count) and [`servers[].threads.event.priority`](#confval-servers-.threads.event.priority).

<a id="confval-servers-.threads.event.id"></a>

### servers[].threads.event.id

<sub>Only applies to smtp servers</sub>

The name of the [`threads.events[].id`](#confval-threads.events-.id). This property is required if configured with custom event threads.

<a id="confval-servers-.threads.event.count"></a>

### servers[].threads.event.count

The number of [`servers[]`](config_smtpd.html.md#confval-servers) event loop threads, allowing the event loop to take
advantage of multiple CPUs. The default is 4.

<a id="confval-servers-.threads.event.priority"></a>

### servers[].threads.event.priority

<sub>Only applies to smtp servers</sub>

The priority (nice value) of the thread, from -20 to 19 (default 0). A smaller value means higher priority.

> **Note**
> 
> Don’t forget to update this value as well [`environment.rlimit.nice`](#confval-environment.rlimit.nice).

<a id="confval-servers-.threads.script"></a>

### servers[].threads.script

The number of [`servers[]`](config_smtpd.html.md#confval-servers) [script](https://docs.halon.io/hsl/archive/6.12-stable/) threads running the hooks
such as [`servers[].phases.eod.hook`](config_smtpd.html.md#confval-servers-.phases.eod.hook). If given as a number (and not an object), a script thread pool will be created
named after the [`servers[].id`](#confval-servers-.id) (prefixed with an underscore) with the [`servers[].scripting.concurrency`](#confval-servers-.scripting.concurrency) and [`servers[].scripting.stacksize`](#confval-servers-.scripting.stacksize).
The default is 32.

<a id="confval-servers-.threads.script.id"></a>

### servers[].threads.script.id

The name of the default [`threads.scripts[].id`](#confval-threads.scripts-.id). This property is required if configured with custom hook threads, and it will be used for any
un-configured hooks.

<a id="confval-servers-.threads.script.hooks.connect"></a>

### servers[].threads.script.hooks.connect

<sub>Only applies to smtp servers</sub>

The name of the [`threads.scripts[].id`](#confval-threads.scripts-.id) for the connect hook.

<a id="confval-servers-.threads.script.hooks.proxy"></a>

### servers[].threads.script.hooks.proxy

<sub>Only applies to smtp servers</sub>

The name of the [`threads.scripts[].id`](#confval-threads.scripts-.id) for the proxy hook.

<a id="confval-servers-.threads.script.hooks.helo"></a>

### servers[].threads.script.hooks.helo

<sub>Only applies to smtp servers</sub>

The name of the [`threads.scripts[].id`](#confval-threads.scripts-.id) for the helo hook.

<a id="confval-servers-.threads.script.hooks.auth"></a>

### servers[].threads.script.hooks.auth

<sub>Only applies to smtp servers</sub>

The name of the [`threads.scripts[].id`](#confval-threads.scripts-.id) for the auth hook.

<a id="confval-servers-.threads.script.hooks.mailfrom"></a>

### servers[].threads.script.hooks.mailfrom

<sub>Only applies to smtp servers</sub>

The name of the [`threads.scripts[].id`](#confval-threads.scripts-.id) for the mailfrom hook.

<a id="confval-servers-.threads.script.hooks.rcptto"></a>

### servers[].threads.script.hooks.rcptto

<sub>Only applies to smtp servers</sub>

The name of the [`threads.scripts[].id`](#confval-threads.scripts-.id) for the rcptto hook.

<a id="confval-servers-.threads.script.hooks.eod"></a>

### servers[].threads.script.hooks.eod

The name of the [`threads.scripts[].id`](#confval-threads.scripts-.id) for the eod hook.

<a id="confval-servers-.threads.script.hooks.disconnect"></a>

### servers[].threads.script.hooks.disconnect

<sub>Only applies to smtp servers</sub>

The name of the [`threads.scripts[].id`](#confval-threads.scripts-.id) for the disconnect hook.

<a id="confval-servers-.scripting.concurrency"></a>

### servers[].scripting.concurrency

The number of concurrent hooks that may be running concurrently on the [`servers[].threads.script`](#confval-servers-.threads.script).
The default is [`servers[].threads.script`](#confval-servers-.threads.script) (1:1). However using a plugin or function supporting
the HSL suspend functionality more may be running concurrently using cooperative multitasking (M:N).

<a id="confval-servers-.scripting.stacksize"></a>

### servers[].scripting.stacksize

The stack size of a hook. The default is *2097152* bytes (2 MiB).
This setting support byte format syntax (eg. `2MiB`).
This setting shouldn’t be changed without a strong reason and understanding for doing so.

<a id="monitor-directives"></a>

## Monitor directives

A [monitor](api_monitor.html.md) interface allows you to access OpenMetric statistics as well as health check endpoints.

Below is an example for a monitoring interface listening to any IP on port 8080:

```yaml
monitor:
  listener:
    port: 8080
```

<a id="confval-monitor.type"></a>

### monitor.type

The type of the monitor, a monitor can either `http` or `https`. The default is `http`.
The `https` monitor type requires a *monitor.tls.certs.cert* to be configured in the [running configuration](config_smtpd.html.md).

<a id="confval-monitor.listener.port"></a>

### monitor.listener.port

Which TCP port to listen on. This option is mutually exclusive with the [`monitor.listener.path`](#confval-monitor.listener.path) setting.

<a id="confval-monitor.listener.address"></a>

### monitor.listener.address

IPv4 or IPv6 address to listen on.
The default is to listen to all IPv4 and IPv6 addresses.

<a id="confval-monitor.listener.backlog"></a>

### monitor.listener.backlog

The kernel connection backlog. The default is the system default.

<a id="confval-monitor.listener.path"></a>

### monitor.listener.path

Have the monitor socket on a UNIX socket. This option is mutually exclusive with the [`monitor.listener.port`](#confval-monitor.listener.port) setting.

<a id="confval-monitor.listener.owner"></a>

### monitor.listener.owner

This option is only supported with the [`monitor.listener.path`](#confval-monitor.listener.path) setting.

<a id="confval-monitor.listener.group"></a>

### monitor.listener.group

This option is only supported with the [`monitor.listener.path`](#confval-monitor.listener.path) setting.

<a id="confval-monitor.listener.chmod"></a>

### monitor.listener.chmod

This option is only supported with the [`monitor.listener.path`](#confval-monitor.listener.path) setting.

<a id="queue-directives"></a>

## Queue directives

<a id="confval-queues.threads.event"></a>

### queues.threads.event

The [queue](queue.html.md) event loop threads, allowing the event loop to take advantage of multiple CPUs.
If given as a number (and not an object without an ID), a event thread pool will be created named “_queues”.
The default is 4.
If configured as an object you may specify an id of a [`queues.threads.event.id`](#confval-queues.threads.event.id) or
an object with [`queues.threads.event.count`](#confval-queues.threads.event.count) and [`queues.threads.event.priority`](#confval-queues.threads.event.priority).

<a id="confval-queues.threads.event.id"></a>

### queues.threads.event.id

The name of the [`threads.events[].id`](#confval-threads.events-.id). This property is required if configured with custom event threads.

<a id="confval-queues.threads.event.count"></a>

### queues.threads.event.count

The number of [queue](queue.html.md) event loop threads, allowing the event loop to take
advantage of multiple CPUs. The default is 4.

<a id="confval-queues.threads.event.priority"></a>

### queues.threads.event.priority

The priority (nice value) of the thread, from -20 to 19 (default 0). A smaller value means higher priority.

> **Note**
> 
> Don’t forget to update this value as well [`environment.rlimit.nice`](#confval-environment.rlimit.nice).

<a id="confval-queues.threads.script"></a>

### queues.threads.script

The number of [queue](queue.html.md)  [script](https://docs.halon.io/hsl/archive/6.12-stable/) threads running the
[`scripting.hooks.predelivery`](config_smtpd.html.md#confval-scripting.hooks.predelivery) and
[`scripting.hooks.postdelivery`](config_smtpd.html.md#confval-scripting.hooks.postdelivery) hooks.
If given as a number (and not an object), a script thread pool will be created
named “_queues” with the [`queues.scripting.concurrency`](#confval-queues.scripting.concurrency) and [`queues.scripting.stacksize`](#confval-queues.scripting.stacksize).
The default is 32.

<a id="confval-queues.threads.script.id"></a>

### queues.threads.script.id

The name of the default [`threads.scripts[].id`](#confval-threads.scripts-.id). This property is required if configured with custom hook threads, and it will be used for any
un-configured hooks.

<a id="confval-queues.threads.script.hooks.predelivery"></a>

### queues.threads.script.hooks.predelivery

The name of the [`threads.scripts[].id`](#confval-threads.scripts-.id) for the predelivery hook.

<a id="confval-queues.threads.script.hooks.postdelivery"></a>

### queues.threads.script.hooks.postdelivery

The name of the [`threads.scripts[].id`](#confval-threads.scripts-.id) for the postdelivery hook.

```yaml
queues:
  threads:
    script:
      id: tpool1 # need a default
      hooks:
        predelivery: tpool1
        postdelivery: tpool2
threads:
  scripts:
    - id: tpool1
      count: 8
    - id: tpool2
      count: 16
```

<a id="confval-queues.threads.pickup"></a>

### queues.threads.pickup

If given as a number of threads preparing messages to be delivered from the active queue.
The default is 1. If configured as an object see [`queues.threads.pickup.count`](#confval-queues.threads.pickup.count).

<a id="confval-queues.threads.pickup.count"></a>

### queues.threads.pickup.count

The number of threads preparing messages to be delivered from the active queue.
The default is 1.

<a id="confval-queues.threads.pickup.priority"></a>

### queues.threads.pickup.priority

The priority (nice value) of the thread, from -20 to 19 (default 0). A smaller value means higher priority.

> **Note**
> 
> Don’t forget to update this value as well [`environment.rlimit.nice`](#confval-environment.rlimit.nice).

<a id="confval-queues.threads.fetch.priority"></a>

### queues.threads.fetch.priority

The priority (nice value) of the thread fetching messages from the queue, from -20 to 19 (default 0). A smaller value means higher priority.

<a id="confval-queues.threads.rate.priority"></a>

### queues.threads.rate.priority

The priority (nice value) of the thread refilling queue policy rates, from -20 to 19 (default 0). A smaller value means higher priority.

<a id="confval-queues.threads.release.priority"></a>

### queues.threads.release.priority

The priority (nice value) of the thread flagging delivered messages (somewhat like the opposite of [`queues.threads.pickup`](#confval-queues.threads.pickup)), from -20 to 19 (default 0). A smaller value means higher priority.

<a id="confval-queues.scripting.concurrency"></a>

### queues.scripting.concurrency

The number of concurrent hooks that may be running concurrently on the [`queues.threads.script`](#confval-queues.threads.script).
The default is [`queues.threads.script`](#confval-queues.threads.script) (1:1). However using a plugin or function supporting
the HSL suspend functionality more may be running concurrently using cooperative multitasking (M:N).

<a id="confval-queues.scripting.stacksize"></a>

### queues.scripting.stacksize

The stack size of a hook. The default is *2097152* bytes (2 MiB).
This setting support byte format syntax (eg. `2MiB`).
This setting shouldn’t be changed without a strong reason and understanding for doing so.

<a id="confval-spool.path"></a>

### spool.path

The email queue spool path. This option is mutually exclusive with [`spool.paths[].path`](#confval-spool.paths-.path). The default is  */var/spool/halon/queue*.

<a id="confval-spool.paths-.path"></a>

### spool.paths[].path

The email queue spool paths (multiple paths). The paths are used in a round-robin fashion to spread load evenly.
This option is mutually exclusive with [`spool.path`](#confval-spool.path). The default is  */var/spool/halon/queue*.
During spool in messages are spooled in the order they are specified in the configuration.

<a id="confval-spool.paths-.write"></a>

### spool.paths[].write

If the path should used when receiving messages (or just consuming existing messages in that path). The default is *true*.

<a id="confval-spool.fsync"></a>

### spool.fsync

If *fsync* operations should be used for the email queue. The default is *true*.

<a id="confval-spool.minfree.inodes"></a>

### spool.minfree.inodes

The minimum required free inodes on the *spool.path* disk. The default is *0*.

<a id="confval-spool.minfree.bytes"></a>

### spool.minfree.bytes

The minimum required free bytes on the *spool.path* disk.
This setting support byte format syntax (eg. `5GiB`).
The default is *0*.

<a id="confval-spool.loader.threads"></a>

### spool.loader.threads

If given as a number of threads that read the [spool files](queue_load.html.md#queue-ondisk) into memory during startup.
Those are terminated once the spool is loaded. The default is 32.
If configured as an object see [`spool.loader.threads.count`](#confval-spool.loader.threads.count).

<a id="confval-spool.loader.threads.count"></a>

### spool.loader.threads.count

The number of threads that read the [spool files](queue_load.html.md#queue-ondisk) into memory during startup.
The default is 32.

<a id="confval-spool.loader.threads.priority"></a>

### spool.loader.threads.priority

The priority (nice value) of the thread, from -20 to 19 (default 0). A smaller value means higher priority.

> **Note**
> 
> Don’t forget to update this value as well [`environment.rlimit.nice`](#confval-environment.rlimit.nice).

<a id="confval-spool.loader.wait"></a>

### spool.loader.wait

If the startup process should wait for the loader to spool in all messages. This allows quotas etc to be properly
updated before new messages are accepted. For faster startup times, this can be disabled. The default is *true*.

<a id="confval-spool.loader.corrupt"></a>

### spool.loader.corrupt

How to handle incomplete or corrupt queue (.hqf) files upon startup. The default action is `unlink`.
But it is also possible to `rename` those (appending  *.bad*) or `ignore` to do nothing.

<a id="confval-spool.loader.rate"></a>

### spool.loader.rate

Specify the rate (`files/seconds`) of which messages will be spooled in from disk.
This (in combination with `spool.loader.threads.wait`) allows you to reduce the load caused by spool in while receiving new messages.
The default is no limitation.

<a id="confval-spool.update.threads"></a>

### spool.update.threads

The maximum number of synchronous worker threads for API or CLI [queue update](cli_queue.html.md#halonctl-queue)
of the [spool files](queue_load.html.md#queue-ondisk).
The default is 32.
If configured as an object see [`spool.loader.threads.count`](#confval-spool.loader.threads.count).

<a id="confval-spool.update.threads.count"></a>

### spool.update.threads.count

The maximum number of synchronous worker threads for API or CLI [queue update](cli_queue.html.md#halonctl-queue)
of the [spool files](queue_load.html.md#queue-ondisk).
The default is 32.

<a id="confval-spool.update.threads.priority"></a>

### spool.update.threads.priority

The priority (nice value) of the thread, from -20 to 19 (default 0). A smaller value means higher priority.

> **Note**
> 
> Don’t forget to update this value as well [`environment.rlimit.nice`](#confval-environment.rlimit.nice).

<a id="confval-spool.update.background.threads.count"></a>

### spool.update.background.threads.count

The maximum number of asynchronous (background) worker threads for API or CLI [queue update](cli_queue.html.md#halonctl-queue)
of the [spool files](queue_load.html.md#queue-ondisk).
The default is 32.

<a id="confval-spool.update.background.threads.priority"></a>

### spool.update.background.threads.priority

The priority (nice value) of the thread, from -20 to 19 (default 0). A smaller value means higher priority.

> **Note**
> 
> Don’t forget to update this value as well [`environment.rlimit.nice`](#confval-environment.rlimit.nice).

<a id="confval-spool.update.background.rate"></a>

### spool.update.background.rate

Specify the rate (`messages/seconds`) of which messages will be updated.
This allows you to reduce the impact when doing bulk update while processing messages.
The default is no limitation.

<a id="threads-directives"></a>

## Threads directives

<a id="scripts"></a>

### Scripts

Custom script thread pools allows you to control on which script thread pools a script / hook is executed.

<a id="confval-threads.scripts-.id"></a>

#### threads.scripts[].id

The name of the script thread pool

<a id="confval-threads.scripts-.count"></a>

#### threads.scripts[].count

The number of scripts threads running a hooks
such as [`servers[].phases.eod.hook`](config_smtpd.html.md#confval-servers-.phases.eod.hook).
The default is 32.

<a id="confval-threads.scripts-.priority"></a>

#### threads.scripts[].priority

The priority (nice value) of the thread, from -20 to 19 (default 0). A smaller value means higher priority.

> **Note**
> 
> Don’t forget to update this value as well [`environment.rlimit.nice`](#confval-environment.rlimit.nice).

<a id="confval-threads.scripts-.concurrency"></a>

#### threads.scripts[].concurrency

The number of concurrent hooks that may be running concurrently.
The default is [`threads.scripts[].count`](#confval-threads.scripts-.count) (1:1). However using a plugin or function supporting
the HSL suspend functionality more may be running concurrently using cooperative multitasking (M:N).

<a id="confval-threads.scripts-.stacksize"></a>

#### threads.scripts[].stacksize

The stack size of a hook. The default is *2097152* bytes (2 MiB).
This setting support byte format syntax (eg. `2MiB`).
This setting shouldn’t be changed without a strong reason and understanding for doing so.

<a id="events"></a>

### Events

Custom event thread pools allows you to control on which thread pools a network event is processed.

<a id="confval-threads.events-.id"></a>

#### threads.events[].id

The name of the events thread pool

<a id="confval-threads.events-.count"></a>

#### threads.events[].count

The number of events threads running network events.
The default is 4.

<a id="confval-threads.events-.priority"></a>

#### threads.events[].priority

The priority (nice value) of the thread, from -20 to 19 (default 0). A smaller value means higher priority.

> **Note**
> 
> Don’t forget to update this value as well [`environment.rlimit.nice`](#confval-environment.rlimit.nice).

<a id="other-directives"></a>

## Other directives

<a id="confval-resolver.threads.event"></a>

### resolver.threads.event

Number of DNS resolver event pool threads. The default is 1.

<a id="confval-resolver.threads.ready"></a>

### resolver.threads.ready

Number of threads processing ready resolvings. The default is 1.

<a id="confval-resolver.ednsbuffersize"></a>

### resolver.ednsbuffersize

The EDNS buffer size. The default is `1280`, as per [RFC8200](https://www.rfc-editor.org/rfc/rfc8200.html).
You can change this value if necessary to suit your network, e.g. to reduce UDP packet fragmentation and fallback to TCP.

<a id="confval-plugins"></a>

### plugins[]

Load the following plugins into the MTA. The `id` and `path` properties are required. An optional *config* object or YAML path may be specified for the plugin’s configuration. A similar *config* property is also available in the [running configuration](config_smtpd.html.md).

```yaml
plugins:
  - id: test
    path: "/opt/halon/plugins/test.so"
    config:
      myval: true
```

<a id="confval-plugins-.config"></a>

### plugins[].config

The startup configuration. This property may be either a string or an YAML object.
If this property is given as a string it must point to a YAML file on disk.

<a id="confval-pki.private"></a>

### pki.private[]

Array of private keys, possibly with X.509 certificates, for use with [`servers[]`](config_smtpd.html.md#confval-servers) and [script](https://docs.halon.io/hsl/archive/6.12-stable/) functions such as
PKCS7, RSA, DKIM, client certificates, etc.

The `id` and `privatekey` properties are required, and `certificate` is optional.
The private key and certificate should have either a `path` or `data` property.

```yaml
pki:
  private:
    - id: selfsigned
      certificate:
        data: |-
          -----BEGIN CERTIFICATE-----
          ...
      privatekey:
        data: |-
          -----BEGIN PRIVATE KEY-----
          ...
```

> **Note**
> 
> It is also possible to add those to the [running configuration](config_smtpd.html.md),
> but for privilege separation reasons it’s normally recommended to define private keys here
> instead, as this startup configuration is read before the privilege drop.
> It is however possible to load the private key from a path in this startup configuration,
> and load the certificate from a path in running configuration, which allows you to softly
> reload the certificate when it changes, as long as the private key stays the same.

<a id="confval-scripting.ffi"></a>

### scripting.ffi

Enable the use of [FFI](https://docs.halon.io/hsl/archive/6.12-stable/functions.html#ffi) functions
from the [script](https://docs.halon.io/hsl/archive/6.12-stable/) language. The default is false.

<a id="confval-scripting.rootpath"></a>

### scripting.rootpath

Enable accessing files from disk via the [File](https://docs.halon.io/hsl/archive/6.12-stable/functions.html#File) class
and the [`scripting.files[]`](config_smtpd.html.md#confval-scripting.files) path, relative from the specified root path. The default is to
not allow accessing files on disk.

<a id="confval-scripting.cache.scope"></a>

### scripting.cache.scope

Configure the [script](https://docs.halon.io/hsl/archive/6.12-stable/) language `cache []` statement scope. It can either be `global` (a persistent cache between config reloads)
or `config` (to be per config reload or live stage, shared between all hooks).
The default scope is per `config`.

<a id="clustering-directives"></a>

<a id="id1"></a>

## Clustering directives

It’s possible to configure sharing of *concurrency*, *connectinterval* and *rate* settings across a cluster of nodes, using the [Delivery Orchestrator](/clusterd/) service.
See also [Cluster-aware policy](queue_cluster.html.md#cluster-aware-policy).

<a id="confval-cluster.address"></a>

### cluster.address

The peer address of the `clusterd` service.

<a id="confval-cluster.port"></a>

### cluster.port

The peer port of the `clusterd` service. The default is `2530`.

<a id="confval-cluster.startup.hosts"></a>

### cluster.startup.hosts

If it cannot connect on startup, it will default to this many hosts until (when dividing concurrency and rates).
The default is to wait for a connection before starting.
This setting can be set even when [`cluster.address`](#confval-cluster.address) is not set, to set a static number of hosts to divide concurrency and rates by, without using [Delivery Orchestrator](/clusterd/).

<a id="confval-cluster.policy.sharedconcurrency"></a>

### cluster.policy.sharedconcurrency

If the concurrency should be shared in the cluster (this is the opposite of evenly divide based on the number of hosts connected).
The default is `true`.

<a id="confval-cluster.tls.id"></a>

### cluster.tls.id

The id of the client certificate TLS (PKI) certificate to use.

<a id="confval-cluster.tls.verify"></a>

### cluster.tls.verify

If the server peer certificate should be verified. The default is `true`.

<a id="confval-cluster.tls.verifyname"></a>

### cluster.tls.verifyname

Hostname to verify against the server certificate’s CN and SAN.

<a id="environment-directives"></a>

## Environment directives

The default startup configuration that came with the installation package
contains reasonable defaults for your platform. Some settings should however
be revised.

<a id="performance-and-log"></a>

### Performance and log

Those settings are typically configured depending on your
system and use case.

<a id="confval-environment.rlimit.nofile"></a>

#### environment.rlimit.nofile

Set the max number of open file descriptors (this changes the current process limit from system default `ulimit -n`).
This value should be calculated from other limits to allow the server to allocate system resources as needed.
There is no downside of specifying a value larger than needed, so there is no reason to be conservative (just make sure it fits within system limits).
The most dominant values in the configuration has the biggest impact on the result, so for simplicity in most cases you may use a quite simple formula like this.

The sum of [`servers[].concurrency.total`](config_smtpd.html.md#confval-servers-.concurrency.total), [`queues.concurrency.total`](config_smtpd.html.md#confval-queues.concurrency.total) and [`queues.pooling.size`](config_smtpd.html.md#confval-queues.pooling.size) multiplying
by `5` and adding a fixed value of eg. `10000` (to safely cover other limits such a script thread usage and DNS etc). Even if this value comes out twice or more than what is actual
needed it should be used as a safety margin.

```default
((1000 + 10000 + 1000) * 5) + 10000 = 70000
```

Given the potential complexity of the calculation, which also depends on how the scripting is used, we cannot safely list all other values that need to be considered.
In most cases we estimate that these should all fit within the margin of the calculation (both in multiplication factor and also the fixed value added).
However, for transparency here is a few.

* smtpd’s file descriptors, used for various things
* [`servers[].listeners[]`](#confval-servers-.listeners)
* [`servers[].threads.script`](#confval-servers-.threads.script)
* [`queues.threads.script`](#confval-queues.threads.script)
* [`spool.update.threads`](#confval-spool.update.threads)
* [`resolver.threads.event`](#confval-resolver.threads.event)

The Linux kernel has two limits, the `sysctl fs.file-max` which is the upper limit of fd in the OS kernel and `sysctl fs.nr_open` which controls the upper limit of ulimit command. It’s important that they are larger than the [`environment.rlimit.nofile`](#confval-environment.rlimit.nofile) specified.

<a id="confval-environment.rlimit.nice"></a>

#### environment.rlimit.nice

Set the the highest priority (lowest nice value) a thread can request (this changes the current process limit from system default `ulimit -e`), from -20 to 19 (default 0). A smaller value means higher priority.

<a id="confval-environment.syslog.mask"></a>

#### environment.syslog.mask

If you are using `systemd-journald` for `syslog()`, we strongly recommend
masking away `LOG_INFO` (non-error email transaction) for performance reasons
by setting this option to 191.
For transaction logging you can use a module from our [script library](https://docs.halon.io/go/scriptlibrary)
such as Elastic, libjlog or syslog directly to rsyslog.
The default is no mask.

<a id="confval-environment.syslog.ident"></a>

#### environment.syslog.ident

The syslog identity. The default is the program name.

<a id="confval-environment.syslog.facility"></a>

#### environment.syslog.facility

The syslog facility. Valid options are `daemon`, `mail`, `user`, `local0`, `local1`, `local2`, `local3`, `local4`, `local5`, `local6` and `local7`. The default is `mail`.

<a id="confval-environment.syslog.pid"></a>

#### environment.syslog.pid

Log the process ID. The default is false.

<a id="configuration-paths"></a>

### Configuration paths

Those paths can normally be left unchanged.

<a id="confval-environment.appconf"></a>

#### environment.appconf

From where to load the [running configuration](config_smtpd.html.md).
The default is  */etc/halon/smtpd-app.yaml*.

<a id="confval-environment.policyconf"></a>

#### environment.policyconf

From where to load the  [active queue policies](queue_policy.html.md#queue-policy).
The default is  */etc/halon/smtpd-policy.yaml*.

<a id="confval-environment.suspendconf"></a>

#### environment.suspendconf

From where to load the  [active queue suspends](queue_suspend.html.md#queue-suspend).
The default is  */etc/halon/smtpd-suspend.yaml*.

<a id="confval-environment.deliveryconf"></a>

#### environment.deliveryconf

From where to load the [active queue delivery settings](queue_delivery.html.md#queue-delivery).
The default is  */etc/halon/smtpd-delivery.yaml*.

<a id="confval-environment.licensekey"></a>

#### environment.licensekey

From where to load the license.
The default is `/etc/halon/license.key`.
A license key may also be loaded from the environment variable `HALON_LICENSEKEY`,
the should contain the license file content base64 encoded.
The environment variable has precedence over this [`environment.licensekey`](#confval-environment.licensekey) setting.

<a id="confval-environment.pluginspath"></a>

#### environment.pluginspath

From where to load plugins.
The default is `/etc/halon/plugins`.

<a id="other-environment"></a>

### Other environment

Those settings should normally be left unchanged.
The default startup configuration in  */opt/halon/examples*
that came with the installation package should contain
correct parameters for your operating system or distribution.

<a id="confval-environment.controlsocket.path"></a>

#### environment.controlsocket.path

Have the control socket on a UNIX socket. This option is mutually exclusive with the [`environment.controlsocket.port`](#confval-environment.controlsocket.port) setting.

<a id="confval-environment.controlsocket.owner"></a>

#### environment.controlsocket.owner

This option is only supported with the [`environment.controlsocket.path`](#confval-environment.controlsocket.path) setting.

<a id="confval-environment.controlsocket.group"></a>

#### environment.controlsocket.group

This option is only supported with the [`environment.controlsocket.path`](#confval-environment.controlsocket.path) setting.

<a id="confval-environment.controlsocket.chmod"></a>

#### environment.controlsocket.chmod

This option is only supported with the [`environment.controlsocket.path`](#confval-environment.controlsocket.path) setting.

<a id="confval-environment.controlsocket.port"></a>

#### environment.controlsocket.port

Have the control socket on a TCP port. This option is mutually exclusive with the [`environment.controlsocket.path`](#confval-environment.controlsocket.path) setting.

<a id="confval-environment.controlsocket.address"></a>

#### environment.controlsocket.address

Have the control socket listen on a specific IP address. This option is only supported with the [`environment.controlsocket.port`](#confval-environment.controlsocket.port) setting.

<a id="confval-environment.controlsocket.tls"></a>

#### environment.controlsocket.tls

TLS settings for the control socket when using [`environment.controlsocket.port`](#confval-environment.controlsocket.port). The default is no TLS.

<a id="confval-environment.controlsocket.tls.cert"></a>

#### environment.controlsocket.tls.cert

Which [`pki.private[]`](#confval-pki.private) to use for TLS on the control socket.

<a id="confval-environment.controlsocket.tls.cacerts"></a>

#### environment.controlsocket.tls.cacerts[]

A list of X.509 CA certificates for client certificate authentication, either a `path` or `data` property.
This feature will disable looking at the system-wide certificate store.

<a id="confval-environment.controlsocket.tls.lookupdirs.paths"></a>

#### environment.controlsocket.tls.lookupdirs.paths[]

A list of paths to lookup `openssl rehash`ed certificates and CRLs.

<a id="confval-environment.controlsocket.tls.lookupdirs.crl"></a>

#### environment.controlsocket.tls.lookupdirs.crl

If CRL checking should be done (searching in the lookupdirs). The default is `false`.

<a id="confval-environment.controlsocket.tls.crls"></a>

#### environment.controlsocket.tls.crls[]

A list of X.509 Certificate revokelists (CRL) for client certificate authentication, either a `path` or `data` property.

<a id="confval-environment.controlsocket.tls.clientcerts"></a>

#### environment.controlsocket.tls.clientcerts[]

A list of X.509 certificates for client certificate authentication, either a `path` or `data` property.
This feature is mutually exclusive with clientnames.

<a id="confval-environment.controlsocket.tls.clientnames"></a>

#### environment.controlsocket.tls.clientnames[]

The client certificates names that the server should trust. Supports wildcards eg. `.example.net`. This feature is mutually exclusive with clientcerts.

<a id="confval-environment.controlsocket.tls.client"></a>

#### environment.controlsocket.tls.client

The TLS settings for the [command line interface](cli.html.md).

<a id="confval-environment.controlsocket.tls.client.certificate"></a>

#### environment.controlsocket.tls.client.certificate

The client certificate to use. This setting should have either a `path` or `data` property.

<a id="confval-environment.controlsocket.tls.client.privatekey"></a>

#### environment.controlsocket.tls.client.privatekey

The private key for the client certificate. This setting should have either a `path` or `data` property.

<a id="confval-environment.controlsocket.tls.client.verify"></a>

#### environment.controlsocket.tls.client.verify

If the server peer certificate should be verified. The default is `true`.

<a id="confval-environment.controlsocket.tls.client.verifyname"></a>

#### environment.controlsocket.tls.client.verifyname

Hostname to verify against the server certificate’s CN and SAN.

<a id="confval-environment.controlsocket.backlog"></a>

#### environment.controlsocket.backlog

The kernel connection backlog. The default is the system default.

<a id="confval-environment.controlsocket.logging.audit"></a>

#### environment.controlsocket.logging.audit

If detailed audit logging should be enabled. The default is `true`.

<a id="confval-environment.privdrop.user"></a>

#### environment.privdrop.user

The user to run the process as.

<a id="confval-environment.privdrop.group"></a>

#### environment.privdrop.group

The group to run the process as.

<a id="confval-environment.publicsuffix"></a>

#### environment.publicsuffix

The path to a publicsuffix list (publicsuffix.org).

<a id="confval-environment.umask"></a>

#### environment.umask

Change the umask for file creation. The default is often *022*.

<a id="confval-environment.uuid.version"></a>

#### environment.uuid.version

There are two supported methods of UUID generation: time based version 1 and random version 4. The default is *1* and it requires safe UUIDs to be generated (which is tested for upon smtpd startup). Safe in this context means it has to be thread-safe; assisted by the operating system/implementation (either by a syscall, a daemon such as *uuidd* or file locking). Depending on the environment the preferred way may differ. If you cannot use any of these, we also offer version *4* which is random based. The probably of collision of random UUIDs are so low they should be considered [safe](https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_(random)).
