github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/website/pages/docs/job-specification/restart.mdx (about) 1 --- 2 layout: docs 3 page_title: restart Stanza - Job Specification 4 sidebar_title: restart 5 description: The "restart" stanza configures a group's behavior on task failure. 6 --- 7 8 # `restart` Stanza 9 10 <Placement 11 groups={[ 12 ['job', 'group', 'restart'], 13 ['job', 'group', 'task', 'restart'] 14 ]} 15 /> 16 17 The `restart` stanza configures a tasks's behavior on task failure. Restarts 18 happen on the client that is running the task. 19 20 ```hcl 21 job "docs" { 22 group "example" { 23 restart { 24 attempts = 3 25 delay = "30s" 26 } 27 } 28 } 29 ``` 30 31 If specified at the group level, the configuration is inherited by all 32 tasks in the group. If present on the task, the policy is merged with 33 the restart policy from the encapsulating task group. 34 35 For example, assuming that the task group restart policy is: 36 ```hcl 37 restart { 38 interval = "30m" 39 attempts = 2 40 delay = "15s" 41 mode = "fail" 42 } 43 ``` 44 and the individual task restart policy is: 45 ```hcl 46 restart { 47 attempts = 5 48 } 49 ``` 50 then the effective restart policy for the task will be: 51 ```hcl 52 restart { 53 interval = "30m" 54 attempts = 5 55 delay = "15s" 56 mode = "fail" 57 } 58 ``` 59 60 ## `restart` Parameters 61 62 - `attempts` `(int: <varies>)` - Specifies the number of restarts allowed in the 63 configured interval. Defaults vary by job type, see below for more 64 information. 65 66 - `delay` `(string: "15s")` - Specifies the duration to wait before restarting a 67 task. This is specified using a label suffix like "30s" or "1h". A random 68 jitter of up to 25% is added to the delay. 69 70 - `interval` `(string: <varies>)` - Specifies the duration which begins when the 71 first task starts and ensures that only `attempts` number of restarts happens 72 within it. If more than `attempts` number of failures happen, behavior is 73 controlled by `mode`. This is specified using a label suffix like "30s" or 74 "1h". Defaults vary by job type, see below for more information. 75 76 - `mode` `(string: "fail")` - Controls the behavior when the task fails more 77 than `attempts` times in an interval. For a detailed explanation of these 78 values and their behavior, please see the [mode values section](#mode-values). 79 80 ### `restart` Parameter Defaults 81 82 The values for many of the `restart` parameters vary by job type. Here are the 83 defaults by job type: 84 85 - The default batch restart policy is: 86 87 ```hcl 88 restart { 89 attempts = 3 90 delay = "15s" 91 interval = "24h" 92 mode = "fail" 93 } 94 ``` 95 96 - The default service and system job restart policy is: 97 98 ```hcl 99 restart { 100 interval = "30m" 101 attempts = 2 102 delay = "15s" 103 mode = "fail" 104 } 105 ``` 106 107 ### `mode` Values 108 109 This section details the specific values for the "mode" parameter in the Nomad 110 job specification for constraints. The mode is always specified as a string 111 112 ```hcl 113 restart { 114 mode = "..." 115 } 116 ``` 117 118 - `"delay"` - Instructs the scheduler to delay the next restart until the next 119 `interval` is reached. 120 121 - `"fail"` - Instructs the scheduler to not attempt to restart the task on 122 failure. This is the default behavior. This mode is useful for non-idempotent jobs which are unlikely to 123 succeed after a few failures. Failed jobs will be restarted according to 124 the [`reschedule`](/docs/job-specification/reschedule) stanza.