github.com/smintz/nomad@v0.8.3/website/source/docs/job-specification/restart.html.md (about)

     1  ---
     2  layout: "docs"
     3  page_title: "restart Stanza - Job Specification"
     4  sidebar_current: "docs-job-specification-restart"
     5  description: |-
     6    The "restart" stanza configures a group's behavior on task failure.
     7  ---
     8  
     9  # `restart` Stanza
    10  
    11  <table class="table table-bordered table-striped">
    12    <tr>
    13      <th width="120">Placement</th>
    14      <td>
    15        <code>job -> group -> **restart**</code>
    16      </td>
    17    </tr>
    18  </table>
    19  
    20  The `restart` stanza configures a group's behavior on task failure. Restarts
    21  happen on the client that is running the task.
    22  
    23  ```hcl
    24  job "docs" {
    25    group "example" {
    26      restart {
    27        attempts = 3
    28        delay    = "30s"
    29      }
    30    }
    31  }
    32  ```
    33  
    34  ## `restart` Parameters
    35  
    36  - `attempts` `(int: <varies>)` - Specifies the number of restarts allowed in the
    37    configured interval. Defaults vary by job type, see below for more
    38    information.
    39  
    40  - `delay` `(string: "15s")` - Specifies the duration to wait before restarting a
    41    task. This is specified using a label suffix like "30s" or "1h". A random
    42    jitter of up to 25% is added to the delay.
    43  
    44  - `interval` `(string: <varies>)` - Specifies the duration which begins when the
    45    first task starts and ensures that only `attempts` number of restarts happens
    46    within it. If more than `attempts` number of failures happen, behavior is
    47    controlled by `mode`. This is specified using a label suffix like "30s" or
    48    "1h". Defaults vary by job type, see below for more information.
    49  
    50  - `mode` `(string: "delay")` - Controls the behavior when the task fails more
    51    than `attempts` times in an interval. For a detailed explanation of these
    52    values and their behavior, please see the [mode values section](#mode-values).
    53  
    54  ### `restart` Parameter Defaults
    55  
    56  The values for many of the `restart` parameters vary by job type. Here are the
    57  defaults by job type:
    58  
    59  - The default batch restart policy is:
    60  
    61      ```hcl
    62      restart {
    63        attempts = 15
    64        delay    = "15s"
    65        interval = "168h"
    66        mode     = "fail"
    67      }
    68      ```
    69  
    70  - The default non-batch restart policy is:
    71  
    72      ```hcl
    73      restart {
    74        interval = "1m"
    75        attempts = 2
    76        delay    = "15s"
    77        mode     = "fail"
    78      }
    79      ```
    80  
    81  
    82  ### `mode` Values
    83  
    84  This section details the specific values for the "mode" parameter in the Nomad
    85  job specification for constraints. The mode is always specified as a string
    86  
    87  ```hcl
    88  restart {
    89    mode = "..."
    90  }
    91  ```
    92  
    93  - `"delay"` - Instructs the scheduler to delay the next restart until the next
    94    `interval` is reached. This is the default behavior.
    95  
    96  - `"fail"` - Instructs the scheduler to not attempt to restart the task on
    97    failure. This mode is useful for non-idempotent jobs which are unlikely to
    98    succeed after a few failures.