mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-13 21:56:38 +01:00
feat: add --health-check command line switch (#1725)
Co-authored-by: nils måsén <nils@piksel.se>
This commit is contained in:
parent
79ebad0e19
commit
8e3bde7e0b
6 changed files with 35 additions and 1 deletions
10
cmd/root.go
10
cmd/root.go
|
|
@ -140,6 +140,16 @@ 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 {
|
||||
time.Sleep(1 * time.Second)
|
||||
log.Fatal("The health check flag should never be passed to the main watchtower container process")
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
if rollingRestart && monitorOnly {
|
||||
log.Fatal("Rolling restarts is not compatible with the global monitor only flag")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue