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