From 46690698a4b9eaa7326c739a938b79ea2ce9da7b Mon Sep 17 00:00:00 2001 From: M S Vishwanath Bhat Date: Wed, 1 Aug 2018 16:36:52 +0200 Subject: [PATCH 1/3] systemd unit - Restart on failure Signed-off-by: M S Vishwanath Bhat --- dist/systemd/nomad.service | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dist/systemd/nomad.service b/dist/systemd/nomad.service index 331d2f313..4e7a7b740 100644 --- a/dist/systemd/nomad.service +++ b/dist/systemd/nomad.service @@ -7,6 +7,8 @@ KillMode=process KillSignal=SIGINT ExecStart=/usr/bin/nomad agent -config /etc/nomad ExecReload=/bin/kill -HUP $MAINPID +Restart=on-failure +RestartSec=30 LimitNOFILE=65536 [Install] From 1fd96ebb36644b560d842ae1a4062e85ac3e8697 Mon Sep 17 00:00:00 2001 From: M S Vishwanath Bhat Date: Wed, 1 Aug 2018 16:59:24 +0200 Subject: [PATCH 2/3] systemd unit - Wait for Network to be online This patch configures nomad to start only after the network is up and online. Signed-off-by: M S Vishwanath Bhat --- dist/systemd/nomad.service | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dist/systemd/nomad.service b/dist/systemd/nomad.service index 4e7a7b740..188c545f4 100644 --- a/dist/systemd/nomad.service +++ b/dist/systemd/nomad.service @@ -1,6 +1,8 @@ [Unit] Description=Nomad Documentation=https://nomadproject.io/docs/ +Wants=network-online.target +After=network-online.target [Service] KillMode=process From 543b212948042e3378278e32f93cd159e1efef58 Mon Sep 17 00:00:00 2001 From: M S Vishwanath Bhat Date: Thu, 2 Aug 2018 12:24:12 +0200 Subject: [PATCH 3/3] systemd unit - Do not restart if unit fails 3 times in 10s Signed-off-by: M S Vishwanath Bhat --- dist/systemd/nomad.service | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dist/systemd/nomad.service b/dist/systemd/nomad.service index 188c545f4..9533c1718 100644 --- a/dist/systemd/nomad.service +++ b/dist/systemd/nomad.service @@ -4,13 +4,20 @@ Documentation=https://nomadproject.io/docs/ Wants=network-online.target After=network-online.target +# If you are running Consul, please uncomment following Wants/After configs. +# Assuming your Consul service unit name is "consul" +#Wants=consul.service +#After=consul.service + [Service] KillMode=process KillSignal=SIGINT ExecStart=/usr/bin/nomad agent -config /etc/nomad ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure -RestartSec=30 +RestartSec=2 +StartLimitBurst=3 +StartLimitIntervalSec=10 LimitNOFILE=65536 [Install]