Whenever the consul.service is configured without a type, type=simple
is used by default. This unit type does not include any type of notification when a service has completed initialization. type=simple
is the recommended type which is shown on the consul product deployment guide, and provided below.
Type=simple(default)
[Unit]
Description="HashiCorp Consul - A service mesh solution"
Documentation=https://www.consul.io/
Requires=network-online.target
After=network-online.target
ConditionFileNotEmpty=/etc/consul.d/consul.hcl
[Service]
EnvironmentFile=-/etc/consul.d/consul.env
User=consul
Group=consul
ExecStart=/usr/bin/consul agent -config-dir=/etc/consul.d/
ExecReload=/bin/kill --signal HUP $MAINPID
KillMode=process
KillSignal=SIGTERM
Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
When type=notify
is used, Consul will wait until it has properly joined one of the agents specified in either join
or retry_join
before signaling to systemd that the process has successfully started. If consul is not sending the health status back to systemd, the consul service will be terminated.
Type=notify
[Unit]
Description="HashiCorp Consul - A service mesh solution"
Documentation=https://www.consul.io/
Requires=network-online.target
After=network-online.target
ConditionFileNotEmpty=/etc/consul.d/consul.hcl
[Service]
Type=notify
EnvironmentFile=-/etc/consul.d/consul.env
User=consul
Group=consul
ExecStart=/usr/bin/consul agent -config-dir=/etc/consul.d/
ExecReload=/bin/kill --signal HUP $MAINPID
KillMode=process
KillSignal=SIGTERM
Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
There are scenarios where consul will not notify systemd that it is in a healthy state. Most of the scenarios are based on environmental issues, which is one reason why type=simple
is the recommended type. type=simple
is the default when installing consul via rpm and deb packages, so consul.service can be left as is to avoid using type=notify
.