github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/e2e/consul/input/on_update_check_restart.nomad (about)

     1  job "test" {
     2    datacenters = ["dc1"]
     3    type        = "service"
     4  
     5    constraint {
     6      attribute = "${attr.kernel.name}"
     7      value     = "linux"
     8    }
     9  
    10  
    11    group "test" {
    12      count = 1
    13  
    14      network {
    15        port "db" {
    16          to = 6379
    17        }
    18      }
    19  
    20      update {
    21        health_check      = "checks"
    22        progress_deadline = "45s"
    23        healthy_deadline  = "30s"
    24      }
    25  
    26      service {
    27        name = "script-check-svc"
    28        port = "db"
    29  
    30        check {
    31          name     = "tcp"
    32          type     = "tcp"
    33          port     = "db"
    34          interval = "10s"
    35          timeout  = "2s"
    36        }
    37  
    38        check {
    39          name      = "script-check-script"
    40          type      = "script"
    41          command   = "/bin/bash"
    42          interval  = "5s"
    43          timeout   = "1s"
    44          task      = "server"
    45          on_update = "ignore_warnings"
    46  
    47          args = [
    48            "-c",
    49            "/local/ready.sh"
    50          ]
    51  
    52          check_restart {
    53            limit           = 2
    54            ignore_warnings = true
    55          }
    56        }
    57      }
    58  
    59  
    60      task "server" {
    61        driver = "docker"
    62  
    63        config {
    64          image = "redis"
    65          ports = ["db"]
    66        }
    67  
    68        # Check script that reports as warning for long enough for deployment to
    69        # become healthy then errors
    70        template {
    71          data = <<EOT
    72  #!/bin/sh
    73  
    74  if [ ! -f /tmp/check_0 ]; then touch /tmp/check_0; exit 1; fi
    75  if [ ! -f /tmp/check_1 ]; then touch /tmp/check_1; exit 1; fi
    76  if [ ! -f /tmp/check_2 ]; then touch /tmp/check_2; exit 1; fi
    77  if [ ! -f /tmp/check_3 ]; then touch /tmp/check_3; exit 1; fi
    78  if [ ! -f /tmp/check_4 ]; then touch /tmp/check_4; exit 1; fi
    79  if [ ! -f /tmp/check_5 ]; then touch /tmp/check_5; exit 1; fi
    80  if [ ! -f /tmp/check_6 ]; then touch /tmp/check_6; exit 7; fi
    81  if [ ! -f /tmp/check_7 ]; then touch /tmp/check_7; exit 7; fi
    82  if [ ! -f /tmp/check_8 ]; then touch /tmp/check_8; exit 7; fi
    83  if [ ! -f /tmp/check_9 ]; then touch /tmp/check_9; exit 7; fi
    84  
    85  
    86  if [ -f /tmp/check_9 ]; then exit 7; fi
    87  EOT
    88  
    89          destination = "local/ready.sh"
    90          perms       = "777"
    91        }
    92      }
    93    }
    94  }
    95