mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-13 21:56:38 +01:00
Add --stop-timeout parameter
This commit is contained in:
parent
fbf6c0d620
commit
6197d96635
3 changed files with 15 additions and 4 deletions
13
main.go
13
main.go
|
|
@ -30,6 +30,7 @@ var (
|
|||
cleanup bool
|
||||
noRestart bool
|
||||
notifier *notifications.Notifier
|
||||
timeout time.Duration
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
|
@ -81,6 +82,12 @@ func main() {
|
|||
Usage: "use TLS and verify the remote",
|
||||
EnvVar: "DOCKER_TLS_VERIFY",
|
||||
},
|
||||
cli.DurationFlag{
|
||||
Name: "stop-timeout",
|
||||
Usage: "timeout before container is forcefully stopped",
|
||||
Value: time.Second * 10,
|
||||
EnvVar: "WATCHTOWER_TIMEOUT",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "label-enable",
|
||||
Usage: "watch containers where the com.centurylinklabs.watchtower.enable label is true",
|
||||
|
|
@ -178,6 +185,10 @@ func before(c *cli.Context) error {
|
|||
|
||||
cleanup = c.GlobalBool("cleanup")
|
||||
noRestart = c.GlobalBool("no-restart")
|
||||
timeout = c.GlobalDuration("stop-timeout")
|
||||
if timeout < 0 {
|
||||
log.Fatal("Please specify a positive value for timeout value.")
|
||||
}
|
||||
|
||||
// configure environment vars for client
|
||||
err := envConfig(c)
|
||||
|
|
@ -209,7 +220,7 @@ func start(c *cli.Context) error {
|
|||
case v := <-tryLockSem:
|
||||
defer func() { tryLockSem <- v }()
|
||||
notifier.StartNotification()
|
||||
if err := actions.Update(client, names, cleanup, noRestart); err != nil {
|
||||
if err := actions.Update(client, names, cleanup, noRestart, timeout); err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
notifier.SendNotification()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue