Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #119 from w3c/agt-docker
Browse files Browse the repository at this point in the history
Agt docker
  • Loading branch information
UlfBj authored Feb 29, 2024
2 parents 769a62d + 945a251 commit 8bb066f
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 12 deletions.
2 changes: 1 addition & 1 deletion client/client-1.0/grpc_client/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var clientCert tls.Certificate
var caCertPool x509.CertPool

const (
address = "127.0.0.1"
address = "0.0.0.0"
name = "VISSv2-gRPC-client"
)

Expand Down
13 changes: 12 additions & 1 deletion docker/viss-docker-rl/docker-compose-rl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,44 @@ services:
feeder-rl:
container_name: feeder-rl
user: root
depends_on:
- redis
build:
context: ../../
dockerfile: Dockerfile.rlserver
target: feeder
entrypoint: [/app/feeder,--dataprovider, remotive, --rdb, /tmp/docker/redisDB.sock,--fch,/tmp/docker/server-feeder-channel.sock]
ports:
- "443:443"
#volumes:
#volumes:
#- ./feeder/feeder-rl/certificate.pem:/app/certificate.pem
#- ./feeder/feeder-rl/config.json:/app/config.json
#- ./feeder/feeder-rl/VehicleVssMapData.json:/app/VehicleVssMapData.json
volumes_from:
- tmp


redis:
image: redis
container_name: app_redis
privileged: true
user: root
command: redis-server /etc/redis.conf
ports:
- "6379:6379"
volumes:
- ../../redis/redis.conf:/etc/redis.conf
volumes_from:
- tmp




vissv2server:
container_name: vissv2server
depends_on:
- redis
- feeder-rl
build:
context: ../../ # context set to repo root
dockerfile: Dockerfile.rlserver
Expand Down
1 change: 0 additions & 1 deletion server/vissv2server/grpcMgr/grpcMgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ func (s *Server) GetRequest(ctx context.Context, in *pb.GetRequestMessage) (*pb.
grpcResponseChan := make(chan string)
var grpcRequestMessage = GrpcRequestMessage{vssReq, grpcResponseChan}
utils.Info.Println(grpcRequestMessage.VssReq)
// fmt.Println("*****************" + grpcRequestMessage.VssReq + "*****************")
grpcClientChan[0] <- grpcRequestMessage // forward to mgr hub,
vssResp := <-grpcResponseChan // and wait for response
pbResp := utils.GetResponseJsonToPb(vssResp, grpcCompression)
Expand Down
10 changes: 8 additions & 2 deletions server/vissv2server/serviceMgr/serviceMgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -944,23 +944,29 @@ func ServiceMgrInit(mgrId int, serviceMgrChan chan string, stateStorageType stri
utils.Error.Printf("Could not find state storage file = %s", dbFile)
}
case "redis":
addr := utils.GetUdsPath("Vehicle", "redis")
utils.Info.Printf(addr)
redisClient = redis.NewClient(&redis.Options{
Network: "unix",
Addr: utils.GetUdsPath("Vehicle", "serverFeeder"), //TODO replace with check and exit if not defined.
Addr: addr, //TODO replace with check and exit if not defined.
Password: "",
DB: 1,
})
err := redisClient.Ping().Err()
if err != nil {
utils.Error.Printf("redis-server ,ping err = %s", err)
if utils.FileExists("redis.log") {
os.Remove("redis.log")
}
cmd := exec.Command("/usr/bin/bash", "redisNativeInit.sh")
err := cmd.Run()
if err != nil {
utils.Error.Printf("redis-server startup failed, err=%s", err)
os.Exit(1)
// os.Exit(1) should terminate the process
return
}
} else {
utils.Info.Printf("Redis state ping is ok")
}
utils.Info.Printf("Redis state storage initialised.")
case "apache-iotdb":
Expand Down
16 changes: 9 additions & 7 deletions utils/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,18 @@ type UdsReg struct {

var udsRegList []UdsReg

func ReadUdsRegistrations(sockFile string) {
func ReadUdsRegistrations(sockFile string) []UdsReg {
data, err := os.ReadFile(sockFile)
if err != nil {
Error.Printf("readUdsRegistrations():%s error=%s", sockFile, err)
return
return nil
}
err = json.Unmarshal(data, &udsRegList)
if err != nil {
Error.Printf("readUdsRegistrations():unmarshal error=%s", err)
return
return nil
}
return
return udsRegList
}

func GetUdsConn(path string, connectionName string) net.Conn {
Expand All @@ -83,11 +83,13 @@ func GetUdsConn(path string, connectionName string) net.Conn {

func GetUdsPath(path string, connectionName string) string {
root := ExtractRootName(path)
Info.Printf("GetUdsPath:root=%s, connectionName=%s", root, connectionName)
for i := 0; i < len(udsRegList); i++ {
if root == udsRegList[i].RootName {
getSocketPath(i, connectionName)
return getSocketPath(i, connectionName)
}
}
Info.Printf("could not find root name")
return ""
}

Expand Down Expand Up @@ -323,8 +325,8 @@ func FileExists(filename string) bool {
func ExtractRootName(path string) string {
dotDelimiter := strings.Index(path, ".")
if dotDelimiter == -1 {
Error.Print("ExtractRootName():Could not find root node name in path=%s", path)
return ""
Info.Print("ExtractRootName():Could not find root node name in path=%s", path)
return path
}
return path[:dotDelimiter]
}
Expand Down
14 changes: 14 additions & 0 deletions utils/common_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/******** Peter Winzell (c), 2/28/24 *********************************************/
package utils

import (
"testing"
)

// Testing UDS json file parsing
func TestUdsRegistration(t *testing.T) {
udsRegList := ReadUdsRegistrations("../vissv2server/uds-registration.docker.json")
for i, item := range udsRegList {
t.Logf("Item %d: %s", i, item)
}
}

0 comments on commit 8bb066f

Please sign in to comment.