be04bfed34
* Clean up handling of subprocesses and make using a shell optional * Update docs for subprocess changes * Fix tests for new subprocess behavior * More cleanup of subprocesses * Minor adjustments and cleanup for subprocess logic * Makes the watch handler reload test use the new path. * Adds check tests for new args path, and updates existing tests to use new path. * Adds support for script args in Docker checks. * Fixes the sanitize unit test. * Adds panic for unknown watch type, and reverts back to Run(). * Adds shell option back to consul lock command. * Adds shell option back to consul exec command. * Adds shell back into consul watch command. * Refactors signal forwarding and makes Windows-friendly. * Adds a clarifying comment. * Changes error wording to a warning. * Scopes signals to interrupt and kill. This avoids us trying to send SIGCHILD to the dead process. * Adds an error for shell=false for consul exec. * Adds notes about the deprecated script and handler fields. * De-nests an if statement.
79 lines
2 KiB
Go
79 lines
2 KiB
Go
package structs
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/hashicorp/consul/api"
|
|
"github.com/hashicorp/consul/types"
|
|
)
|
|
|
|
// CheckDefinition is used to JSON decode the Check definitions
|
|
type CheckDefinition struct {
|
|
ID types.CheckID
|
|
Name string
|
|
Notes string
|
|
ServiceID string
|
|
Token string
|
|
Status string
|
|
|
|
// Copied fields from CheckType without the fields
|
|
// already present in CheckDefinition:
|
|
//
|
|
// ID (CheckID), Name, Status, Notes
|
|
//
|
|
Script string
|
|
ScriptArgs []string
|
|
HTTP string
|
|
Header map[string][]string
|
|
Method string
|
|
TCP string
|
|
Interval time.Duration
|
|
DockerContainerID string
|
|
Shell string
|
|
TLSSkipVerify bool
|
|
Timeout time.Duration
|
|
TTL time.Duration
|
|
DeregisterCriticalServiceAfter time.Duration
|
|
}
|
|
|
|
func (c *CheckDefinition) HealthCheck(node string) *HealthCheck {
|
|
health := &HealthCheck{
|
|
Node: node,
|
|
CheckID: c.ID,
|
|
Name: c.Name,
|
|
Status: api.HealthCritical,
|
|
Notes: c.Notes,
|
|
ServiceID: c.ServiceID,
|
|
}
|
|
if c.Status != "" {
|
|
health.Status = c.Status
|
|
}
|
|
if health.CheckID == "" && health.Name != "" {
|
|
health.CheckID = types.CheckID(health.Name)
|
|
}
|
|
return health
|
|
}
|
|
|
|
func (c *CheckDefinition) CheckType() *CheckType {
|
|
return &CheckType{
|
|
CheckID: c.ID,
|
|
Name: c.Name,
|
|
Status: c.Status,
|
|
Notes: c.Notes,
|
|
|
|
Script: c.Script,
|
|
ScriptArgs: c.ScriptArgs,
|
|
HTTP: c.HTTP,
|
|
Header: c.Header,
|
|
Method: c.Method,
|
|
TCP: c.TCP,
|
|
Interval: c.Interval,
|
|
DockerContainerID: c.DockerContainerID,
|
|
Shell: c.Shell,
|
|
TLSSkipVerify: c.TLSSkipVerify,
|
|
Timeout: c.Timeout,
|
|
TTL: c.TTL,
|
|
DeregisterCriticalServiceAfter: c.DeregisterCriticalServiceAfter,
|
|
}
|
|
}
|