结合上一期 Dapr(一) 基于云原生了解Dapr(Dapr(一) 基于云原生了解Dapr-CSDN博客)
目录
2.3 Dapr_ServiceA Program.cs修改
2.4 Dapr_ServiceA ServiceAController.cs
2.5 Dapr_ServiceB ServiceBController.cs
3.1 Dapr_ServiceA和Dapr_ServiceB复制粘贴至Linux系统下的dapr文件夹下。
4.1 浏览器输入 192.168.157.157/2000/swagger/index.html 192.168.157.157/3000/swagger/index.html
1. Dapr单机环境部署应用
1.1 ping github.com
Dapr单机版需要从github进行下载,我们只能用魔法才能打败魔法。我们开启魔法之后,在Linux系统中使用 ping github.com
Linux虚拟机已经成功 ping 通 github.com。
1.2 安装dapr环境
下载shell脚本 https://raw.githubusercontent.com/dapr/cli/master/install/install.sh
#!/usr/bin/env bash
# ------------------------------------------------------------
# Copyright 2021 The Dapr Authors
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ------------------------------------------------------------
# Dapr CLI location
: ${DAPR_INSTALL_DIR:="/usr/local/bin"}
# sudo is required to copy binary to DAPR_INSTALL_DIR for linux
: ${USE_SUDO:="false"}
# Http request CLI
DAPR_HTTP_REQUEST_CLI=curl
# GitHub Organization and repo name to download release
GITHUB_ORG=dapr
GITHUB_REPO=cli
# Dapr CLI filename
DAPR_CLI_FILENAME=dapr
DAPR_CLI_FILE="${DAPR_INSTALL_DIR}/${DAPR_CLI_FILENAME}"
getSystemInfo() {
ARCH=$(uname -m)
case $ARCH in
armv7*) ARCH="arm";;
aarch64) ARCH="arm64";;
x86_64) ARCH="amd64";;
esac
OS=$(echo `uname`|tr '[:upper:]' '[:lower:]')
# Most linux distro needs root permission to copy the file to /usr/local/bin
if [[ "$OS" == "linux" || "$OS" == "darwin" ]] && [ "$DAPR_INSTALL_DIR" == "/usr/local/bin" ]; then
USE_SUDO="true"
fi
}
verifySupported() {
releaseTag=$1
local supported=(darwin-amd64 linux-amd64 linux-arm linux-arm64)
local current_osarch="${OS}-${ARCH}"
for osarch in "${supported[@]}"; do
if [ "$osarch" == "$current_osarch" ]; then
echo "Your system is ${OS}_${ARCH}"
return
fi
done
if [ "$current_osarch" == "darwin-arm64" ]; then
if isReleaseAvailable $releaseTag; then
return
else
echo "The darwin_arm64 arch has no native binary for this version of Dapr, however you can use the amd64 version so long as you have rosetta installed"
echo "Use 'softwareupdate --install-rosetta' to install rosetta if you don't already have it"
ARCH="amd64"
return
fi
fi
echo "No prebuilt binary for ${current_osarch}"
exit 1
}
runAsRoot() {
local CMD="$*"
if [ $EUID -ne 0 -a $USE_SUDO = "true" ]; then
CMD="sudo $CMD"
fi
$CMD || {
echo "Please visit https://docs.dapr.io/getting-started/install-dapr-cli/ for instructions on how to install without sudo."
exit 1
}
}
checkHttpRequestCLI() {
if type "curl" > /dev/null; then
DAPR_HTTP_REQUEST_CLI=curl
elif type "wget" > /dev/null; then
DAPR_HTTP_REQUEST_CLI=wget
else
echo "Either curl or wget is required"
exit 1
fi
}
checkExistingDapr() {
if [ -f "$DAPR_CLI_FILE" ]; then
echo -e "\nDapr CLI is detected:"
$DAPR_CLI_FILE --version
echo -e "Reinstalling Dapr CLI - ${DAPR_CLI_FILE}...\n"
else
echo -e "Installing Dapr CLI...\n"
fi
}
getLatestRelease() {
local daprReleaseUrl="https://ap