github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/e2e/consul/input/checks_group_restart.nomad (about)

     1  job "group_check_restart" {
     2    datacenters = ["dc1"]
     3    type        = "service"
     4  
     5    constraint {
     6      attribute = "${attr.kernel.name}"
     7      value     = "linux"
     8    }
     9  
    10    group "group_check_restart" {
    11      network {
    12        mode = "bridge"
    13      }
    14  
    15      restart {
    16        attempts = 2
    17        delay    = "1s"
    18        interval = "5m"
    19        mode     = "fail"
    20      }
    21  
    22      service {
    23        name = "group-service-1"
    24        port = "9003"
    25  
    26        # this check should always time out and so the service
    27        # should not be marked healthy, resulting in the tasks
    28        # getting restarted
    29        check {
    30          name     = "always-dead"
    31          type     = "script"
    32          task     = "fail"
    33          interval = "2s"
    34          timeout  = "1s"
    35          command  = "sleep"
    36          args     = ["10"]
    37  
    38          check_restart {
    39            limit           = 2
    40            grace           = "5s"
    41            ignore_warnings = false
    42          }
    43        }
    44      }
    45  
    46      task "fail" {
    47        driver = "raw_exec"
    48  
    49        config {
    50          command = "bash"
    51          args    = ["-c", "sleep 15000"]
    52        }
    53      }
    54  
    55      task "ok" {
    56        driver = "raw_exec"
    57  
    58        config {
    59          command = "bash"
    60          args    = ["-c", "sleep 15000"]
    61        }
    62      }
    63    }
    64  }