github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/e2e/consul/input/checks_group.nomad (about)

     1  job "group_check" {
     2    datacenters = ["dc1"]
     3    type        = "service"
     4  
     5    constraint {
     6      attribute = "${attr.kernel.name}"
     7      value     = "linux"
     8    }
     9  
    10    group "group_check" {
    11      network {
    12        mode = "bridge"
    13      }
    14  
    15      service {
    16        name = "group-service-1"
    17        port = "9001"
    18  
    19        check {
    20          name     = "alive-1"
    21          type     = "script"
    22          task     = "test"
    23          interval = "2s"
    24          timeout  = "2s"
    25          command  = "echo"
    26          args     = ["alive-1"]
    27        }
    28      }
    29  
    30      service {
    31        name = "group-service-2"
    32        port = "9002"
    33  
    34        check {
    35          name     = "alive-2a"
    36          type     = "script"
    37          task     = "test"
    38          interval = "2s"
    39          timeout  = "2s"
    40          command  = "echo"
    41          args     = ["alive-2a"]
    42        }
    43  
    44        # the file expected by this check will not exist when started,
    45        # so the check will error-out and be in a warning state until
    46        # it's been created
    47        check {
    48          name     = "alive-2b"
    49          type     = "script"
    50          task     = "test"
    51          interval = "2s"
    52          timeout  = "2s"
    53          command  = "cat"
    54          args     = ["/tmp/${NOMAD_ALLOC_ID}-alive-2b"]
    55        }
    56      }
    57  
    58      service {
    59        name = "group-service-3"
    60        port = "9003"
    61  
    62        # this check should always time out and so the service
    63        # should not be marked healthy
    64        check {
    65          name     = "always-dead"
    66          type     = "script"
    67          task     = "test"
    68          interval = "2s"
    69          timeout  = "1s"
    70          command  = "sleep"
    71          args     = ["10"]
    72        }
    73      }
    74  
    75      count = 1
    76  
    77      task "test" {
    78        driver = "raw_exec"
    79  
    80        config {
    81          command = "bash"
    82          args    = ["-c", "sleep 15000"]
    83        }
    84      }
    85    }
    86  }