fix(watchdog): Close dangling file descriptors on shutdown and config reload (#544)
* fix(watchdog): Add functions to avoid dangling file descriptors * Change function name and add comment under core/endpoint.go - change the function name of CloseHTTPConnection() to Close() - add some comments above Close() function * Update core/endpoint.go * Update core/endpoint.go --------- Co-authored-by: Richard Cheng <richard_cheng@trendmicro.com> Co-authored-by: TwiN <twin@linux.com>
This commit is contained in:
@ -364,6 +364,15 @@ func (endpoint *Endpoint) call(result *Result) {
|
||||
}
|
||||
}
|
||||
|
||||
// Close HTTP connections between watchdog and endpoints to avoid dangling socket file descriptors
|
||||
// on configuration reload.
|
||||
// More context on https://github.com/TwiN/gatus/issues/536
|
||||
func (endpoint *Endpoint) Close() {
|
||||
if endpoint.Type() == EndpointTypeHTTP {
|
||||
client.GetHTTPClient(endpoint.ClientConfig).CloseIdleConnections()
|
||||
}
|
||||
}
|
||||
|
||||
func (endpoint *Endpoint) buildHTTPRequest() *http.Request {
|
||||
var bodyBuffer *bytes.Buffer
|
||||
if endpoint.GraphQL {
|
||||
|
Reference in New Issue
Block a user