This repository has been archived by the owner on Sep 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
run-databroker.sh
executable file
·100 lines (83 loc) · 4.03 KB
/
run-databroker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
#********************************************************************************
# Copyright (c) 2022 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License 2.0 which is available at
# http://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
#*******************************************************************************/
# shellcheck disable=SC2086
# shellcheck disable=SC2181
echo "#######################################################"
echo "### Running Databroker ###"
echo "#######################################################"
set -e
ROOT_DIRECTORY=$(git rev-parse --show-toplevel)
# shellcheck source=/dev/null
source "$ROOT_DIRECTORY/.vscode/scripts/task-common.sh" "$@"
### NOTE: DATABROKER_* variables are defined in task-common.sh
# # Databroker App port
# DATABROKER_PORT='55555'
# # Databroker Dapr Sidecar gRPC port
# DATABROKER_GRPC_PORT='52001'
# # Dapr app id for databroker
# VEHICLEDATABROKER_DAPR_APP_ID='vehicledatabroker'
export DAPR_GRPC_PORT=$DATABROKER_GRPC_PORT
DATABROKER_VERSION=$(jq -r '.databroker.version // empty' "$CONFIG_JSON")
if [ -z "$DATABROKER_VERSION" ]; then
echo "Coudln't find databroker version from $CONFIG_JSON"
exit 1
fi
# https://github.com/eclipse/kuksa.val/releases/download/0.3.0/databroker-amd64.tar.gz
### change introduced since databroker 0.3.0 release, zip file containing tar.gz
# https://github.com/eclipse/kuksa.val/releases/download/0.4.0/databroker-amd64.zip
DATABROKER_BINARY_ZIP="databroker-$PROCESSOR_ALT.zip"
DATABROKER_BINARY_NAME="databroker-$PROCESSOR_ALT.tar.gz"
DATABROKER_BINARY_PATH="$ROOT_DIRECTORY/.vscode/scripts/assets/databroker/$DATABROKER_VERSION/$PROCESSOR_ALT"
DATABROKER_EXECUTABLE="$DATABROKER_BINARY_PATH/databroker/databroker"
DOWNLOAD_URL="https://github.com/eclipse/kuksa.val/releases/download/$DATABROKER_VERSION/$DATABROKER_BINARY_ZIP"
download_zip_release "$DATABROKER_EXECUTABLE" "$DOWNLOAD_URL" "$DATABROKER_BINARY_PATH" "$DATABROKER_BINARY_ZIP" "$DATABROKER_BINARY_NAME" || exit 1
### Data Broker environment setup ###
## Uncomment for feed values debug
export RUST_LOG="debug,databroker=debug,vehicle_data_broker=debug,h2=info"
##export GRPC_TRACE=all,-timer,-timer_check
##export GRPC_VERBOSITY=DEBUG
### pre-load vss json versions
if [ ! -f $DATABROKER_BINARY_PATH/vss3.json ] || [ ! -f $DATABROKER_BINARY_PATH/vss4.json ]; then
echo "# Downloading $DATABROKER_BINARY_PATH/vss*.json ..."
wget -q "https://raw.githubusercontent.com/eclipse/kuksa.val/master/data/vss-core/vss_release_3.0.json" -O "$DATABROKER_BINARY_PATH/vss3.json"
wget -q "https://raw.githubusercontent.com/eclipse/kuksa.val/master/data/vss-core/vss_release_4.0.json" -O "$DATABROKER_BINARY_PATH/vss4.json"
fi
if [ "$USE_VSS3" = "1" ]; then
DATABROKER_METADATA="--metadata $DATABROKER_BINARY_PATH/vss3.json"
else
DATABROKER_METADATA="--metadata $DATABROKER_BINARY_PATH/vss4.json"
fi
echo
echo "*******************************************"
echo "* Kuksa Data Broker app-id: $VEHICLEDATABROKER_DAPR_APP_ID"
echo "* Kuksa Data Broker APP port: $DATABROKER_PORT"
echo "* Kuksa Data Broker Dapr sidecar port: $DATABROKER_GRPC_PORT"
echo "* DAPR_GRPC_PORT=$DAPR_GRPC_PORT"
echo "* Dapr metadata: [ VEHICLEDATABROKER_DAPR_APP_ID=$VEHICLEDATABROKER_DAPR_APP_ID ]"
[ -n "$DATABROKER_METADATA" ] && echo "* Kuksa Data Broker Metadata: $DATABROKER_METADATA"
echo "*******************************************"
echo
## Uncomment for dapr debug logs
# DAPR_OPT="--enable-api-logging --log-level debug"
DAPR_OPT="--log-level warn"
dapr run \
--app-id "$VEHICLEDATABROKER_DAPR_APP_ID" \
--app-protocol grpc \
--app-port $DATABROKER_PORT \
--dapr-grpc-port $DATABROKER_GRPC_PORT \
$DAPR_OPT \
--components-path "$ROOT_DIRECTORY/.dapr/components" \
--config "$ROOT_DIRECTORY/.dapr/config.yaml" \
& # -- \
$DATABROKER_EXECUTABLE --address 0.0.0.0 $DATABROKER_METADATA