mirror of
https://github.com/containrrr/watchtower.git
synced 2026-02-04 06:31:48 +01:00
Merge branch 'main' into healthcheck
This commit is contained in:
commit
246da4da68
31 changed files with 745 additions and 986 deletions
61
cmd/root.go
61
cmd/root.go
|
|
@ -1,6 +1,7 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"math"
|
||||
"net/http"
|
||||
"os"
|
||||
|
|
@ -28,17 +29,18 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
client container.Client
|
||||
scheduleSpec string
|
||||
cleanup bool
|
||||
noRestart bool
|
||||
monitorOnly bool
|
||||
enableLabel bool
|
||||
notifier t.Notifier
|
||||
timeout time.Duration
|
||||
lifecycleHooks bool
|
||||
rollingRestart bool
|
||||
scope string
|
||||
client container.Client
|
||||
scheduleSpec string
|
||||
cleanup bool
|
||||
noRestart bool
|
||||
monitorOnly bool
|
||||
enableLabel bool
|
||||
notifier t.Notifier
|
||||
timeout time.Duration
|
||||
lifecycleHooks bool
|
||||
rollingRestart bool
|
||||
scope string
|
||||
labelPrecedence bool
|
||||
)
|
||||
|
||||
var rootCmd = NewRootCommand()
|
||||
|
|
@ -77,23 +79,8 @@ func Execute() {
|
|||
func PreRun(cmd *cobra.Command, _ []string) {
|
||||
f := cmd.PersistentFlags()
|
||||
flags.ProcessFlagAliases(f)
|
||||
|
||||
if enabled, _ := f.GetBool("no-color"); enabled {
|
||||
log.SetFormatter(&log.TextFormatter{
|
||||
DisableColors: true,
|
||||
})
|
||||
} else {
|
||||
// enable logrus built-in support for https://bixense.com/clicolors/
|
||||
log.SetFormatter(&log.TextFormatter{
|
||||
EnvironmentOverrideColors: true,
|
||||
})
|
||||
}
|
||||
|
||||
rawLogLevel, _ := f.GetString(`log-level`)
|
||||
if logLevel, err := log.ParseLevel(rawLogLevel); err != nil {
|
||||
log.Fatalf("Invalid log level: %s", err.Error())
|
||||
} else {
|
||||
log.SetLevel(logLevel)
|
||||
if err := flags.SetupLogging(f); err != nil {
|
||||
log.Fatalf("Failed to initialize logging: %s", err.Error())
|
||||
}
|
||||
|
||||
scheduleSpec, _ = f.GetString("schedule")
|
||||
|
|
@ -109,6 +96,7 @@ func PreRun(cmd *cobra.Command, _ []string) {
|
|||
lifecycleHooks, _ = f.GetBool("enable-lifecycle-hooks")
|
||||
rollingRestart, _ = f.GetBool("rolling-restart")
|
||||
scope, _ = f.GetString("scope")
|
||||
labelPrecedence, _ = f.GetBool("label-take-precedence")
|
||||
|
||||
if scope != "" {
|
||||
log.Debugf(`Using scope %q`, scope)
|
||||
|
|
@ -209,7 +197,7 @@ func Run(c *cobra.Command, names []string) {
|
|||
httpAPI.RegisterHandler(metricsHandler.Path, metricsHandler.Handle)
|
||||
}
|
||||
|
||||
if err := httpAPI.Start(enableUpdateAPI && !unblockHTTPAPI); err != nil && err != http.ErrServerClosed {
|
||||
if err := httpAPI.Start(enableUpdateAPI && !unblockHTTPAPI); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||
log.Error("failed to start API", err)
|
||||
}
|
||||
|
||||
|
|
@ -369,13 +357,14 @@ func runUpgradesOnSchedule(c *cobra.Command, filter t.Filter, filtering string,
|
|||
func runUpdatesWithNotifications(filter t.Filter) *metrics.Metric {
|
||||
notifier.StartNotification()
|
||||
updateParams := t.UpdateParams{
|
||||
Filter: filter,
|
||||
Cleanup: cleanup,
|
||||
NoRestart: noRestart,
|
||||
Timeout: timeout,
|
||||
MonitorOnly: monitorOnly,
|
||||
LifecycleHooks: lifecycleHooks,
|
||||
RollingRestart: rollingRestart,
|
||||
Filter: filter,
|
||||
Cleanup: cleanup,
|
||||
NoRestart: noRestart,
|
||||
Timeout: timeout,
|
||||
MonitorOnly: monitorOnly,
|
||||
LifecycleHooks: lifecycleHooks,
|
||||
RollingRestart: rollingRestart,
|
||||
LabelPrecedence: labelPrecedence,
|
||||
}
|
||||
result, err := actions.Update(client, updateParams)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue