mirror of
https://github.com/kemko/nomad.git
synced 2026-01-04 17:35:43 +03:00
Add restart fields
This commit is contained in:
31
api/tasks.go
31
api/tasks.go
@@ -82,20 +82,23 @@ func (r *RestartPolicy) Merge(rp *RestartPolicy) {
|
||||
// The ServiceCheck data model represents the consul health check that
|
||||
// Nomad registers for a Task
|
||||
type ServiceCheck struct {
|
||||
Id string
|
||||
Name string
|
||||
Type string
|
||||
Command string
|
||||
Args []string
|
||||
Path string
|
||||
Protocol string
|
||||
PortLabel string `mapstructure:"port"`
|
||||
Interval time.Duration
|
||||
Timeout time.Duration
|
||||
InitialStatus string `mapstructure:"initial_status"`
|
||||
TLSSkipVerify bool `mapstructure:"tls_skip_verify"`
|
||||
Header map[string][]string
|
||||
Method string
|
||||
Id string
|
||||
Name string
|
||||
Type string
|
||||
Command string
|
||||
Args []string
|
||||
Path string
|
||||
Protocol string
|
||||
PortLabel string `mapstructure:"port"`
|
||||
Interval time.Duration
|
||||
Timeout time.Duration
|
||||
InitialStatus string `mapstructure:"initial_status"`
|
||||
TLSSkipVerify bool `mapstructure:"tls_skip_verify"`
|
||||
Header map[string][]string
|
||||
Method string
|
||||
RestartAfter int
|
||||
RestartGrace time.Duration
|
||||
RestartWarning bool
|
||||
}
|
||||
|
||||
// The Service model represents a Consul service definition
|
||||
|
||||
@@ -690,19 +690,22 @@ func ApiTaskToStructsTask(apiTask *api.Task, structsTask *structs.Task) {
|
||||
structsTask.Services[i].Checks = make([]*structs.ServiceCheck, l)
|
||||
for j, check := range service.Checks {
|
||||
structsTask.Services[i].Checks[j] = &structs.ServiceCheck{
|
||||
Name: check.Name,
|
||||
Type: check.Type,
|
||||
Command: check.Command,
|
||||
Args: check.Args,
|
||||
Path: check.Path,
|
||||
Protocol: check.Protocol,
|
||||
PortLabel: check.PortLabel,
|
||||
Interval: check.Interval,
|
||||
Timeout: check.Timeout,
|
||||
InitialStatus: check.InitialStatus,
|
||||
TLSSkipVerify: check.TLSSkipVerify,
|
||||
Header: check.Header,
|
||||
Method: check.Method,
|
||||
Name: check.Name,
|
||||
Type: check.Type,
|
||||
Command: check.Command,
|
||||
Args: check.Args,
|
||||
Path: check.Path,
|
||||
Protocol: check.Protocol,
|
||||
PortLabel: check.PortLabel,
|
||||
Interval: check.Interval,
|
||||
Timeout: check.Timeout,
|
||||
InitialStatus: check.InitialStatus,
|
||||
TLSSkipVerify: check.TLSSkipVerify,
|
||||
Header: check.Header,
|
||||
Method: check.Method,
|
||||
RestartAfter: check.RestartAfter,
|
||||
RestartGrace: check.RestartGrace,
|
||||
RestartWarning: check.RestartWarning,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -965,6 +965,9 @@ func parseChecks(service *api.Service, checkObjs *ast.ObjectList) error {
|
||||
"tls_skip_verify",
|
||||
"header",
|
||||
"method",
|
||||
"restart_grace_period",
|
||||
"restart_on_warning",
|
||||
"restart_after_unhealthy",
|
||||
}
|
||||
if err := checkHCLKeys(co.Val, valid); err != nil {
|
||||
return multierror.Prefix(err, "check ->")
|
||||
|
||||
@@ -2775,19 +2775,22 @@ const (
|
||||
// The ServiceCheck data model represents the consul health check that
|
||||
// Nomad registers for a Task
|
||||
type ServiceCheck struct {
|
||||
Name string // Name of the check, defaults to id
|
||||
Type string // Type of the check - tcp, http, docker and script
|
||||
Command string // Command is the command to run for script checks
|
||||
Args []string // Args is a list of argumes for script checks
|
||||
Path string // path of the health check url for http type check
|
||||
Protocol string // Protocol to use if check is http, defaults to http
|
||||
PortLabel string // The port to use for tcp/http checks
|
||||
Interval time.Duration // Interval of the check
|
||||
Timeout time.Duration // Timeout of the response from the check before consul fails the check
|
||||
InitialStatus string // Initial status of the check
|
||||
TLSSkipVerify bool // Skip TLS verification when Protocol=https
|
||||
Method string // HTTP Method to use (GET by default)
|
||||
Header map[string][]string // HTTP Headers for Consul to set when making HTTP checks
|
||||
Name string // Name of the check, defaults to id
|
||||
Type string // Type of the check - tcp, http, docker and script
|
||||
Command string // Command is the command to run for script checks
|
||||
Args []string // Args is a list of argumes for script checks
|
||||
Path string // path of the health check url for http type check
|
||||
Protocol string // Protocol to use if check is http, defaults to http
|
||||
PortLabel string // The port to use for tcp/http checks
|
||||
Interval time.Duration // Interval of the check
|
||||
Timeout time.Duration // Timeout of the response from the check before consul fails the check
|
||||
InitialStatus string // Initial status of the check
|
||||
TLSSkipVerify bool // Skip TLS verification when Protocol=https
|
||||
Method string // HTTP Method to use (GET by default)
|
||||
Header map[string][]string // HTTP Headers for Consul to set when making HTTP checks
|
||||
RestartAfter int // Restart task after this many unhealthy intervals
|
||||
RestartGrace time.Duration // Grace time to give tasks after starting to get healthy
|
||||
RestartWarning bool // If true treat checks in `warning` as unhealthy
|
||||
}
|
||||
|
||||
func (sc *ServiceCheck) Copy() *ServiceCheck {
|
||||
|
||||
Reference in New Issue
Block a user