From 5dac511caee4f3ee0e437b0d2548ce30b9d90dfc Mon Sep 17 00:00:00 2001 From: fancl Date: Thu, 18 Jan 2024 17:13:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=B6=85=E6=97=B6=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/cli/client.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/entry/cli/client.go b/entry/cli/client.go index bfbabf2..8effefa 100644 --- a/entry/cli/client.go +++ b/entry/cli/client.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "git.nspix.com/golang/kos/util/env" "github.com/peterh/liner" "io" "math" @@ -240,14 +241,22 @@ func (client *Client) Close() (err error) { } func NewClient(ctx context.Context, addr string) *Client { + var ( + err error + timeout time.Duration + ) if ctx == nil { ctx = context.Background() } + duration := env.Get("VOX_TIMEOUT", "30s") + if timeout, err = time.ParseDuration(duration); err != nil { + timeout = time.Second * 30 + } return &Client{ ctx: ctx, address: addr, name: filepath.Base(os.Args[0]), - Timeout: time.Second * 30, + Timeout: timeout, liner: liner.NewLiner(), readyChan: make(chan struct{}, 1), exitChan: make(chan struct{}),