github.com/hernad/nomad@v1.6.112/e2e/consul/input/checks_task.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 task "test" { 17 service { 18 name = "task-service-1" 19 20 check { 21 name = "alive-1" 22 type = "script" 23 interval = "2s" 24 timeout = "2s" 25 command = "echo" 26 args = ["alive-1"] 27 } 28 } 29 30 service { 31 name = "task-service-2" 32 33 check { 34 name = "alive-2a" 35 type = "script" 36 interval = "2s" 37 timeout = "2s" 38 command = "echo" 39 args = ["alive-2a"] 40 } 41 42 # the file expected by this check will not exist when started, 43 # so the check will error-out and be in a warning state until 44 # it's been created 45 check { 46 name = "alive-2b" 47 type = "script" 48 interval = "2s" 49 timeout = "2s" 50 command = "cat" 51 args = ["${NOMAD_TASK_DIR}/alive-2b"] 52 } 53 } 54 55 service { 56 name = "task-service-3" 57 58 # this check should always time out and so the service 59 # should not be marked healthy 60 check { 61 name = "always-dead" 62 type = "script" 63 interval = "2s" 64 timeout = "1s" 65 command = "sleep" 66 args = ["10"] 67 } 68 } 69 70 driver = "raw_exec" 71 72 config { 73 command = "bash" 74 args = ["-c", "sleep 15000"] 75 } 76 } 77 } 78 }