mirror of
https://github.com/caddyserver/xcaddy.git
synced 2025-03-09 23:29:06 +01:00
check if context has a deadline (#146)
This commit is contained in:
parent
c9644d6e6b
commit
4227917de2
1 changed files with 7 additions and 2 deletions
|
@ -242,8 +242,13 @@ func parseAndAppendFlags(cmd *exec.Cmd, flags string) *exec.Cmd {
|
|||
}
|
||||
|
||||
func (env environment) runCommand(ctx context.Context, cmd *exec.Cmd) error {
|
||||
deadline, _ := ctx.Deadline()
|
||||
log.Printf("[INFO] exec (timeout=%s): %+v ", time.Until(deadline), cmd)
|
||||
deadline, ok := ctx.Deadline()
|
||||
var timeout time.Duration
|
||||
// context doesn't necessarily have a deadline
|
||||
if ok {
|
||||
timeout = time.Until(deadline)
|
||||
}
|
||||
log.Printf("[INFO] exec (timeout=%s): %+v ", timeout, cmd)
|
||||
|
||||
// start the command; if it fails to start, report error immediately
|
||||
err := cmd.Start()
|
||||
|
|
Loading…
Reference in a new issue