Skip to content

Commit

Permalink
fix: fix the wrong GRPC_PORT number in the corner case when client is…
Browse files Browse the repository at this point in the history
… restarting while re-use the same model server instance

Signed-off-by: Jim Wang <[email protected]>
  • Loading branch information
jim-wang-intel committed Oct 30, 2023
1 parent 98723b0 commit b5c9186
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions configs/opencv-ovms/cmd_client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,15 @@ func (ovmsClientConf *OvmsClientConfig) startOvmsServer() {
fallthrough
case Ignore.String():
log.Println("startup error is ignored due to ignore startup policy")
// in this case, we also need to reset the env $GRPC_PORT to the ignored model server's one
// otherwise, the client will use the wrong port number
ovmsContainerName := ovmsClientConf.OvmsServer.ServerContainerName + os.Getenv(CID_COUNT_ENV)
log.Printf("ovmsContainer name: %s", ovmsContainerName)
ovmsSrvPortNum, err := getServerGrpcPort(ovmsContainerName)
if err != nil {
log.Fatalf("failed to get server gRPC port number: %v", err)
}
os.Setenv(GRPC_PORT_ENV, ovmsSrvPortNum)
}
}

Expand Down
8 changes: 8 additions & 0 deletions configs/opencv-ovms/scripts/get_server_grpc_port.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
#
# Copyright (C) 2023 Intel Corporation.
#
# SPDX-License-Identifier: Apache-2.0
#

docker inspect "$SERVER_CONTAINER_INSTANCE" | docker run -i --rm -v ./:/app ghcr.io/jqlang/jq -r '.[].Args[3]'

0 comments on commit b5c9186

Please sign in to comment.