From e860e62036002e197ffd0806a2f0edf4a5395723 Mon Sep 17 00:00:00 2001 From: mudler Date: Mon, 27 Mar 2023 01:01:10 +0200 Subject: [PATCH] Add mutex, build only lite images --- Earthfile | 4 ++-- api.go | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Earthfile b/Earthfile index 75680d5..b78e17a 100644 --- a/Earthfile +++ b/Earthfile @@ -43,5 +43,5 @@ lite-image: SAVE IMAGE --push $IMAGE-lite image-all: - BUILD --platform=linux/amd64 --platform=linux/arm64 +image - BUILD --platform=linux/amd64 --platform=linux/arm64 +lite-image \ No newline at end of file + #BUILD --platform=linux/amd64 --platform=linux/arm64 +image + BUILD --platform=linux/amd64 --platform=linux/arm64 +lite-image diff --git a/api.go b/api.go index cd000d3..aa65d91 100644 --- a/api.go +++ b/api.go @@ -4,6 +4,7 @@ import ( "embed" "net/http" "strconv" + "sync" llama "github.com/go-skynet/llama/go" "github.com/gofiber/fiber/v2" @@ -28,9 +29,12 @@ func api(l *llama.LLama, listenAddr string, threads int) error { "tokens": 100 }' */ + var mutex = &sync.Mutex{} // Endpoint to generate the prediction app.Post("/predict", func(c *fiber.Ctx) error { + mutex.Lock() + defer mutex.Unlock() // Get input data from the request body input := new(struct { Text string `json:"text"`