Browse Source

use head to check heartbeat

Bruce MacDonald 1 year ago
parent
commit
765994362c
2 changed files with 4 additions and 1 deletions
  1. 1 1
      api/client.go
  2. 3 0
      server/routes.go

+ 1 - 1
api/client.go

@@ -225,7 +225,7 @@ func (c *Client) Delete(ctx context.Context, req *DeleteRequest) error {
 }
 
 func (c *Client) Heartbeat(ctx context.Context) error {
-	if err := c.do(ctx, http.MethodGet, "/", nil, nil); err != nil {
+	if err := c.do(ctx, http.MethodHead, "/", nil, nil); err != nil {
 		return err
 	}
 	return nil

+ 3 - 0
server/routes.go

@@ -319,6 +319,9 @@ func Serve(ln net.Listener) error {
 	r.GET("/", func(c *gin.Context) {
 		c.String(http.StatusOK, "Ollama is running")
 	})
+	r.HEAD("/", func(c *gin.Context) {
+		c.Status(http.StatusOK)
+	})
 
 	r.POST("/api/pull", PullModelHandler)
 	r.POST("/api/generate", GenerateHandler)