Skip to content
This repository has been archived by the owner on May 8, 2023. It is now read-only.

Commit

Permalink
Add flag to configure timeouts for start and restart
Browse files Browse the repository at this point in the history
Fix #46
  • Loading branch information
theothertomelliott committed Apr 5, 2017
1 parent e8ae3d8 commit da2e57d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 9 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ func main() {
Value: &(flags.exclude),
}

timeoutFlag := cli.IntFlag{
Name: "timeout",
Usage: "The amount of time in seconds that Edward will wait for a service to launch before timing out. Defaults to 30",
Destination: &services.StartupTimeoutSeconds,
Value: 30,
}

app.Flags = []cli.Flag{
cli.StringFlag{
Name: "config, c",
Expand Down Expand Up @@ -145,6 +152,7 @@ func main() {
Usage: "After starting, tail logs for services.",
Destination: &(flags.tail),
},
timeoutFlag,
},
},
{
Expand Down Expand Up @@ -178,6 +186,7 @@ func main() {
Usage: "Disable autorestart",
Destination: &(flags.noWatch),
},
timeoutFlag,
},
},
{
Expand Down
6 changes: 5 additions & 1 deletion services/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import (
"github.com/yext/edward/warmup"
)

// StartupTimeoutSeconds is the amount of time in seconds that Edward will wait
// for a service to start before timing out
var StartupTimeoutSeconds = 30

// ServiceCommand provides state and functions for managing a service
type ServiceCommand struct {
// Parent service config
Expand Down Expand Up @@ -282,7 +286,7 @@ func (c *ServiceCommand) waitUntilLive(command *exec.Cmd) error {
return errors.New("service terminated prematurely")
}

timeout := time.NewTimer(30 * time.Second)
timeout := time.NewTimer(time.Duration(StartupTimeoutSeconds) * time.Second)
defer timeout.Stop()

done := make(chan struct{})
Expand Down

0 comments on commit da2e57d

Please sign in to comment.