github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/e2e/consul/input/namespaces/script_checks_task.nomad (about) 1 job "script_checks_task" { 2 datacenters = ["dc1"] 3 type = "service" 4 5 constraint { 6 attribute = "${attr.kernel.name}" 7 value = "linux" 8 } 9 10 group "group-a" { 11 12 consul { 13 namespace = "apple" 14 } 15 16 task "test" { 17 service { 18 name = "service-1a" 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 = "service-2a" 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-2ab" 47 type = "script" 48 interval = "2s" 49 timeout = "2s" 50 command = "cat" 51 args = ["${NOMAD_TASK_DIR}/alive-2ab"] 52 } 53 } 54 55 service { 56 name = "service-3a" 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 79 group "group-z" { 80 81 # consul namespace not set 82 83 task "test" { 84 service { 85 name = "service-1z" 86 87 check { 88 name = "alive-1" 89 type = "script" 90 interval = "2s" 91 timeout = "2s" 92 command = "echo" 93 args = ["alive-1z"] 94 } 95 } 96 97 service { 98 name = "service-2z" 99 100 check { 101 name = "alive-2z" 102 type = "script" 103 interval = "2s" 104 timeout = "2s" 105 command = "echo" 106 args = ["alive-2z"] 107 } 108 109 # the file expected by this check will not exist when started, 110 # so the check will error-out and be in a warning state until 111 # it's been created 112 check { 113 name = "alive-2zb" 114 type = "script" 115 interval = "2s" 116 timeout = "2s" 117 command = "cat" 118 args = ["${NOMAD_TASK_DIR}/alive-2zb"] 119 } 120 } 121 122 service { 123 name = "service-3z" 124 125 # this check should always time out and so the service 126 # should not be marked healthy 127 check { 128 name = "always-dead" 129 type = "script" 130 interval = "2s" 131 timeout = "1s" 132 command = "sleep" 133 args = ["10"] 134 } 135 } 136 137 driver = "raw_exec" 138 139 config { 140 command = "bash" 141 args = ["-c", "sleep 15000"] 142 } 143 } 144 } 145 }