github.com/hernad/nomad@v1.6.112/e2e/consul/input/checks_task_restart.nomad (about)

     1  # Copyright (c) HashiCorp, Inc.
     2  # SPDX-License-Identifier: MPL-2.0
     3  
     4  job "task_check" {
     5    datacenters = ["dc1"]
     6    type        = "service"
     7  
     8    constraint {
     9      attribute = "${attr.kernel.name}"
    10      value     = "linux"
    11    }
    12  
    13    group "task_check" {
    14      count = 1
    15  
    16      restart {
    17        attempts = 2
    18        delay    = "1s"
    19        interval = "5m"
    20        mode     = "fail"
    21      }
    22  
    23      task "fail" {
    24  
    25        service {
    26          name = "task-service-1"
    27  
    28          # this check should always time out and so the service
    29          # should not be marked healthy
    30          check {
    31            name     = "always-dead"
    32            type     = "script"
    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  
    47        driver = "raw_exec"
    48  
    49        config {
    50          command = "bash"
    51          args    = ["-c", "sleep 15000"]
    52        }
    53      }
    54  
    55  
    56      task "ok" {
    57        driver = "raw_exec"
    58  
    59        config {
    60          command = "bash"
    61          args    = ["-c", "sleep 15000"]
    62        }
    63      }
    64  
    65    }
    66  }