diff --git a/Dockerfile b/Dockerfile index 7c3d14b..d65938c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,6 +42,7 @@ RUN apt-get update && \ RUN curl -sL -o /app/model.onnx https://huggingface.co/onnx-community/all-MiniLM-L6-v2-ONNX/resolve/main/onnx/model.onnx && \ curl -sL -o /app/model.onnx_data https://huggingface.co/onnx-community/all-MiniLM-L6-v2-ONNX/resolve/main/onnx/model.onnx_data && \ curl -sL -o /app/tokenizer.json https://huggingface.co/onnx-community/all-MiniLM-L6-v2-ONNX/resolve/main/tokenizer.json && \ + apt-get remove -y curl 2>/dev/null || true && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* diff --git a/go.mod b/go.mod index 2f5b221..f65f4c4 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module vector -go 1.23.0 +go 1.23 require ( github.com/sugarme/tokenizer v0.3.0 diff --git a/main.go b/main.go index 7b18803..98215cb 100644 --- a/main.go +++ b/main.go @@ -6,7 +6,6 @@ import ( "log" "net/http" "os" - "time" "github.com/sugarme/tokenizer" "github.com/sugarme/tokenizer/pretrained" @@ -194,30 +193,6 @@ func vectorHandler(w http.ResponseWriter, r *http.Request) { }) } -type statusRecorder struct { - http.ResponseWriter - status int -} - -func (r *statusRecorder) WriteHeader(code int) { - r.status = code - r.ResponseWriter.WriteHeader(code) -} - -func loggingMiddleware(next http.Handler) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - start := time.Now() - rec := &statusRecorder{ResponseWriter: w, status: http.StatusOK} - next.ServeHTTP(rec, r) - log.Printf("%s %s %s %d %s", r.RemoteAddr, r.Method, r.URL.Path, rec.status, time.Since(start)) - }) -} - -func healthHandler(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json") - json.NewEncoder(w).Encode(map[string]string{"status": "ok"}) -} - func main() { port := os.Getenv("PORT") if port == "" { @@ -225,8 +200,6 @@ func main() { } http.HandleFunc("/vector", vectorHandler) - http.HandleFunc("/ok", healthHandler) - log.SetOutput(os.Stdout) log.Printf("Starting server on port %s...\n", port) - log.Fatal(http.ListenAndServe(":"+port, loggingMiddleware(http.DefaultServeMux))) + log.Fatal(http.ListenAndServe(":"+port, nil)) } diff --git a/server.py b/server.py index 90aa707..9f8e896 100644 --- a/server.py +++ b/server.py @@ -95,7 +95,6 @@ class VectorHandler(BaseHTTPRequestHandler): except Exception as e: self.send_error(500, str(e)) def log_message(self, format, *args): - sys.stdout.write("%s - - [%s] %s\n" % (self.address_string(), self.log_date_time_string(), format % args)) - sys.stdout.flush() + pass # Suppress logs HTTPServer(("0.0.0.0", int(os.getenv("PORT", 8080))), VectorHandler).serve_forever()