X-Git-Url: http://git.giacomolli.uk/onechat/blobdiff_plain/4a605fa39078354654ae648e489c117c7a445197..97274864799ac2eea84bf80c9727a810b695db55:/probe.go?ds=sidebyside diff --git a/probe.go b/probe.go index 6e0b81e..9d272ec 100644 --- a/probe.go +++ b/probe.go @@ -42,8 +42,9 @@ const ( // reports the calls, the time per call, the calls at once, the cached share, // the quota, the retries, and the line sizes. BUILDS, from 1 to maxBuilds, // limits the builds that call the model at once in this run only. The core -// still queues up to maxBuilds builds. -func probe(ctx context.Context, args []string, out io.Writer) error { +// still queues up to maxBuilds builds. The run holds the lock of the token +// file, so it does not run while the daemon runs. +func probe(ctx context.Context, args []string, out io.Writer) (err error) { if len(args) != 2 && len(args) != 3 { return errors.New("usage: onechat probe LOG COUNT [BUILDS]") } @@ -76,6 +77,15 @@ func probe(ctx context.Context, args []string, out io.Writer) error { return err } + tokens, err := lockTokens(dir) + if err != nil { + return err + } + + defer func() { + err = errors.Join(err, tokens.Close()) + }() + address, auth, err := modelEndpoint(config, dir) if err != nil { return err