Skip to main content

Configuring multiple backends

If you want to run Global DCC with multiple road nets you will need to start up multiple backends. You might also want to start multiple backends for the same road net, e.g. to test they can receive messages from the same queue without blocking each other.

Debugging backends for different road nets

To start an additional backend with another road net than the Danish from the /assets folder, you need to add a component for it, setup the road net data and DccMulti.xml, create a docker-compose.override.yml

Create a folder with the new road net data

You need to store the road net on your local machine along with a DccMulti.xml pointing to it. You can copy the /assets folder and make some changes to it. You need to replace the roadnets in the "Roadnet" folder, and adjust the DccMulti.xmls. You might also want to remove the version_1 and version_2 folder, if you are not interested in multiple versions, and you can add road net updates to the Data folders if you want those.

Create docker-compose.override.yml

Add a new file /dev/docker-compose/docker-compose.override.yml. This file should contain configuration for the new backend, its Dapr service, and additional configuration of the new road net for the api.

To the api service docker-compose.override.yml add a new road net config. I.e:

  • Copy the environment variables from docker-compose.yml starting with GlobalDccApiConfig__RoadNets__0__.
  • Replace the 0 with a 1 (because it is the next entry in the array, if you have multiple new road nets the next should replace 0 with 2 etc.).
  • Change the values of Description, and RoadNetId to match the new road net.

To add the backend service and its Dapr service, copy the configuration of the backend and backend-dapr services from docker-compose.yml to docker-compose.override.yml. Then adjust the following:

  • The name of the services should be changed and the DaprService environment variable for the backend should be the new name of the Dapr service.
  • Replace the value of the "--app-id" argument with the name of the new backend service.
  • All port numbers should be changed to new unique port numbers. Do a search and replace on $BackendPort.
  • The values of the backend service's environment variable GlobalDccBackendConfig__RoadNetId should match the new API environment variable GlobalDccApiConfig__RoadNets__1__RoadNetId.
  • Change the backend service's volume to point to the new road net folder from the Create a folder with the new road net data step.
  • For the Dapr service the line <<: *dapr-service will not make sense. So delete this and replace it with a copy of the content of dapr-service from docker-compose.yml.

Example of docker-compose.override.yml:

services:
api:
environment:
GlobalDccApiConfig__RoadNets__1__Description: Belgium
GlobalDccApiConfig__RoadNets__1__RoadNetId: BE

backend-BE:
image: ${DOCKER_REGISTRY-}globaldcc/backend
build:
context: ../../src
args:
FEED_ACCESSTOKEN: #read from host - or overriden by docker-compose.override.yml'
dockerfile: backend/GlobalDcc.Backend.Server/Dockerfile
ports:
- "5033:5033"
environment:
ASPNETCORE_ENVIRONMENT: Development
DAPR_HTTP_PORT: $DaprHttpPort
DAPR_GRPC_PORT: $DaprGrpcPort
DaprService: backend-BE-dapr
GlobalDccBackendConfig__Common__Cache_Dcc__ConnectionString: $CacheConnectionString
GlobalDccBackendConfig__Common__Cache_Dcc__CacheType: $CacheType
GlobalDccBackendConfig__Common__Cache__StorageComponent: $BinaryStorage
GlobalDccBackendConfig__Common__Dapr__PubSubQueue: $PubsubQueue
GlobalDccBackendConfig__Common__Dapr__PubSub: $Pubsub
GlobalDccBackendConfig__Common__Dapr__State: $State
GlobalDccBackendConfig__DataFolderPath: C:\app\data
GlobalDccBackendConfig__RoadNetId: BE
Kestrel__Endpoints__Http__Url: http://0.0.0.0:5033
volumes:
- C:\GlobalDccData\BE:C:\app\data
networks:
- $Network

backend-BE-dapr:
image: "daprio/daprd:1.11.0"
volumes:
- "../../dev/dapr/components/:C:/components:ro"
- "../../dev/dapr/configuration/:C:/configuration:ro"
networks:
- $Network
command: [
"C:/daprd",
"--app-channel-address", "backend-BE",
"--app-id", "backend-BE",
"--app-port", "5033",
"--config", "C:/configuration/config.yaml",
"--dapr-http-port", "$DaprHttpPort",
"--dapr-grpc-port", "$DaprGrpcPort",
"--log-level", "info",
"--resources-path", "C:/components"
]
depends_on:
- backend-BE

Debugging multiple backends for the same road net

It is simpler to start a new backend running on the same road net, than starting one running on another. You do not have to add a new secret, you do not need to create a new road net data folder, you do not need to add environment variables to the api service, and you do not need to make so many changes to the backend and Dapr services.

You still need to create docker-compose.override.yml, and copy the configuration of the backend service, and the backend's Dapr service. The copied services should get new (unique) names and these names should be used for DaprService, --app-channel-address, and depends_on, and the port numbers should also be changed.

Important: The value of --app-id should be the same for the competing consumer pattern to work.

Example of docker-compose.override.yml:

services:
backend2:
image: ${DOCKER_REGISTRY-}globaldcc/backend
build:
context: ../../src
args:
FEED_ACCESSTOKEN: #read from host - or overriden by docker-compose.override.yml'
dockerfile: backend/GlobalDcc.Backend.Server/Dockerfile
ports:
- "5033:5033"
environment:
ASPNETCORE_ENVIRONMENT: Development
DAPR_HTTP_PORT: $DaprHttpPort
DAPR_GRPC_PORT: $DaprGrpcPort
DaprService: backend2-dapr
GlobalDccBackendConfig__Common__Cache_Dcc__ConnectionString: $CacheConnectionString
GlobalDccBackendConfig__Common__Cache_Dcc__CacheType: $CacheType
GlobalDccBackendConfig__Common__Cache__StorageComponent: $BinaryStorage
GlobalDccBackendConfig__Common__Dapr__PubSub: $Pubsub
GlobalDccBackendConfig__Common__Dapr__PubSubQueue: $PubsubQueue
GlobalDccBackendConfig__Common__Dapr__State: $State
GlobalDccBackendConfig__DataFolderPath: C:\app\data
GlobalDccBackendConfig__RoadNetId: local-dev-$USERNAME
Kestrel__Endpoints__Http__Url: http://0.0.0.0:5033
volumes:
- ../../assets:C:\app\data
networks:
- dcc

backend2-dapr:
image: "daprio/daprd:1.11.0"
volumes:
- "../../dev/dapr/components/:C:/components:ro"
- "../../dev/dapr/configuration/:C:/configuration:ro"
networks:
- $Network
command: [
"C:/daprd",
"--app-channel-address", "backend2",
"--app-id", "backend",
"--app-port", "5033",
"--config", "C:/configuration/config.yaml",
"--dapr-http-port", "$DaprHttpPort",
"--dapr-grpc-port", "$DaprGrpcPort",
"--log-level", "info",
"--resources-path", "C:/components"
]
depends_on:
- backend2