mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-16 15:10:12 +01:00
Add --health-check command line switch. Fixes #1257
This commit is contained in:
parent
7948242260
commit
3acc52ed59
6 changed files with 34 additions and 1 deletions
|
|
@ -152,6 +152,15 @@ func Run(c *cobra.Command, names []string) {
|
|||
enableMetricsAPI, _ := c.PersistentFlags().GetBool("http-api-metrics")
|
||||
unblockHTTPAPI, _ := c.PersistentFlags().GetBool("http-api-periodic-polls")
|
||||
apiToken, _ := c.PersistentFlags().GetString("http-api-token")
|
||||
healthCheck, _ := c.PersistentFlags().GetBool("health-check")
|
||||
|
||||
if healthCheck {
|
||||
// health check should not have pid 1
|
||||
if os.Getpid() == 1 {
|
||||
os.Exit(1)
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
if rollingRestart && monitorOnly {
|
||||
log.Fatal("Rolling restarts is not compatible with the global monitor only flag")
|
||||
|
|
|
|||
|
|
@ -17,4 +17,7 @@ COPY --from=alpine \
|
|||
EXPOSE 8080
|
||||
|
||||
COPY watchtower /
|
||||
|
||||
HEALTHCHECK CMD [ "/watchtower", "--health-check"]
|
||||
|
||||
ENTRYPOINT ["/watchtower"]
|
||||
|
|
|
|||
|
|
@ -35,4 +35,6 @@ COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certifi
|
|||
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
|
||||
COPY --from=builder /watchtower/watchtower /watchtower
|
||||
|
||||
HEALTHCHECK CMD [ "/watchtower", "--health-check"]
|
||||
|
||||
ENTRYPOINT ["/watchtower"]
|
||||
|
|
|
|||
|
|
@ -35,4 +35,6 @@ COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certifi
|
|||
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
|
||||
COPY --from=builder /go/watchtower/watchtower /watchtower
|
||||
|
||||
HEALTHCHECK CMD [ "/watchtower", "--health-check"]
|
||||
|
||||
ENTRYPOINT ["/watchtower"]
|
||||
|
|
|
|||
|
|
@ -363,4 +363,15 @@ requests and may rate limit pull requests (mainly docker.io).
|
|||
Environment Variable: WATCHTOWER_WARN_ON_HEAD_FAILURE
|
||||
Possible values: always, auto, never
|
||||
Default: auto
|
||||
```
|
||||
```
|
||||
|
||||
## Health check
|
||||
|
||||
Run health check and exit.
|
||||
|
||||
```text
|
||||
Argument: --health-check
|
||||
Environment Variable: WATCHTOWER_HEALTH_CHECK
|
||||
Possible values: -
|
||||
Default: -
|
||||
```
|
||||
|
|
|
|||
|
|
@ -186,6 +186,12 @@ func RegisterSystemFlags(rootCmd *cobra.Command) {
|
|||
"log-level",
|
||||
viper.GetString("WATCHTOWER_LOG_LEVEL"),
|
||||
"The maximum log level that will be written to STDERR. Possible values: panic, fatal, error, warn, info, debug or trace")
|
||||
|
||||
flags.BoolP(
|
||||
"health-check",
|
||||
"",
|
||||
viper.IsSet("WATCHTOWER_HEALTH_CHECK"),
|
||||
"Do health check and exit")
|
||||
}
|
||||
|
||||
// RegisterNotificationFlags that are used by watchtower to send notifications
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue