Browse Source

Using new check healthy method (#164)

* using new check-healthy method

* update
ryjiang 2 years ago
parent
commit
6f60313dd5
2 changed files with 12 additions and 7 deletions
  1. 1 1
      README.md
  2. 11 6
      server/src/milvus/milvus.service.ts

+ 1 - 1
README.md

@@ -49,7 +49,7 @@ docker run -p 8000:3000 -e MILVUS_URL={milvus server ip}:19530 zilliz/attu:lates
 
 Once you start the container, open the browser, type `http://{ attu ip }:8000`, you can view the attu GUI.
 
-#### Params
+#### Docker CLI parameters
 
 | Parameter  | Example           | required | description                 |
 | :--------- | :---------------- | :------: | --------------------------- |

+ 11 - 6
server/src/milvus/milvus.service.ts

@@ -77,12 +77,17 @@ export class MilvusService {
       const milvusClient: MilvusClient = hasAuth
         ? new MilvusClient(milvusAddress, ssl, username, password)
         : new MilvusClient(milvusAddress, ssl);
-      await milvusClient.collectionManager.hasCollection({
-        collection_name: 'not_exist',
-      });
-      MilvusService.activeAddress = address;
-      cache.set(milvusAddress, milvusClient);
-      return { address };
+
+      // check healthy
+      const res = await milvusClient.checkHealth();
+
+      if (res.isHealthy) {
+        MilvusService.activeAddress = address;
+        cache.set(milvusAddress, milvusClient);
+        return { address };
+      } else {
+        throw new Error('Milvus is not ready yet.');
+      }
     } catch (error) {
       // if milvus is not working, delete connection.
       cache.del(milvusAddress);