forked from miniflux/v2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more extensive healthcheck support
- Add new cli argument: -healthcheck - Add HEALTHCHECK instruction to Dockerfile - Update Docker Compose examples
- Loading branch information
Showing
7 changed files
with
71 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2021 Frédéric Guillot. All rights reserved. | ||
// Use of this source code is governed by the Apache 2.0 | ||
// license that can be found in the LICENSE file. | ||
|
||
package cli // import "miniflux.app/cli" | ||
|
||
import ( | ||
"net/http" | ||
"time" | ||
|
||
"miniflux.app/config" | ||
"miniflux.app/logger" | ||
) | ||
|
||
func doHealthCheck(healthCheckEndpoint string) { | ||
if healthCheckEndpoint == "auto" { | ||
healthCheckEndpoint = "http://" + config.Opts.ListenAddr() + config.Opts.BasePath() + "/healthcheck" | ||
} | ||
|
||
logger.Debug(`Executing health check on %s`, healthCheckEndpoint) | ||
|
||
client := &http.Client{Timeout: 3 * time.Second} | ||
resp, err := client.Get(healthCheckEndpoint) | ||
if err != nil { | ||
logger.Fatal(`Health check failure: %v`, err) | ||
} | ||
defer resp.Body.Close() | ||
|
||
if resp.StatusCode != 200 { | ||
logger.Fatal(`Health check failed with status code %d`, resp.StatusCode) | ||
} | ||
|
||
logger.Debug(`Health check is OK`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters