diff --git a/cmd/root.go b/cmd/root.go index 63a824c..ee64e56 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -1,7 +1,6 @@ package cmd import ( - "github.com/containrrr/watchtower/pkg/filters" "os" "os/signal" "strconv" @@ -11,6 +10,7 @@ import ( "github.com/containrrr/watchtower/internal/actions" "github.com/containrrr/watchtower/internal/flags" "github.com/containrrr/watchtower/pkg/container" + "github.com/containrrr/watchtower/pkg/filters" "github.com/containrrr/watchtower/pkg/notifications" t "github.com/containrrr/watchtower/pkg/types" "github.com/robfig/cron" @@ -123,14 +123,14 @@ func Run(c *cobra.Command, names []string) { log.Fatal(err) } - if err := runUpgradesOnSchedule(filter); err != nil { + if err := runUpgradesOnSchedule(c, filter); err != nil { log.Error(err) } os.Exit(1) } -func runUpgradesOnSchedule(filter t.Filter) error { +func runUpgradesOnSchedule(c *cobra.Command, filter t.Filter) error { tryLockSem := make(chan bool, 1) tryLockSem <- true @@ -156,7 +156,10 @@ func runUpgradesOnSchedule(filter t.Filter) error { return err } - log.Info("Starting Watchtower and scheduling first run: " + cron.Entries()[0].Schedule.Next(time.Now()).String()) + if noStartupMessage, _ := c.PersistentFlags().GetBool("no-startup-message"); !noStartupMessage { + log.Info("Starting Watchtower and scheduling first run: " + cron.Entries()[0].Schedule.Next(time.Now()).String()) + } + cron.Start() // Graceful shut-down on SIGINT/SIGTERM diff --git a/docs/arguments.md b/docs/arguments.md index 19afeba..c172eb8 100644 --- a/docs/arguments.md +++ b/docs/arguments.md @@ -170,6 +170,16 @@ Environment Variable: WATCHTOWER_NO_PULL Default: false ``` +## Without sending a startup message +Do not send a send a message after watchtower started. Otherwise there will be an info-level notification. + +``` + Argument: --no-startup-message +Environment Variable: WATCHTOWER_NO_STARTUP_MESSAGE + Type: Boolean + Default: false +``` + ## Run once Run an update attempt against a container name list one time immediately and exit. diff --git a/internal/flags/flags.go b/internal/flags/flags.go index 7ab09bd..a60d18f 100644 --- a/internal/flags/flags.go +++ b/internal/flags/flags.go @@ -52,6 +52,12 @@ func RegisterSystemFlags(rootCmd *cobra.Command) { viper.GetBool("WATCHTOWER_NO_RESTART"), "do not restart any containers") + flags.BoolP( + "no-startup-message", + "", + viper.GetBool("WATCHTOWER_NO_STARTUP_MESSAGE"), + "Prevents watchtower from sending a startup message") + flags.BoolP( "cleanup", "c",