这是本节的多页打印视图。 点击此处打印.

返回本页常规视图.

概述

Dapr的概述

1 - Dapr的构建

Dapr的构建

build

在项目根目录下执行 :

$ make build
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build  -ldflags="-X github.com/dapr/dapr/pkg/version.commit=v0.8.0-rc.2-96-g79a1f14 -X github.com/dapr/dapr/pkg/version.version=edge -s -w" -o ./dist/darwin_amd64/release/daprd ./cmd/daprd/main.go;
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build  -ldflags="-X github.com/dapr/dapr/pkg/version.commit=v0.8.0-rc.2-96-g79a1f14 -X github.com/dapr/dapr/pkg/version.version=edge -s -w" -o ./dist/darwin_amd64/release/placement ./cmd/placement/main.go;
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build  -ldflags="-X github.com/dapr/dapr/pkg/version.commit=v0.8.0-rc.2-96-g79a1f14 -X github.com/dapr/dapr/pkg/version.version=edge -s -w" -o ./dist/darwin_amd64/release/operator ./cmd/operator/main.go;
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build  -ldflags="-X github.com/dapr/dapr/pkg/version.commit=v0.8.0-rc.2-96-g79a1f14 -X github.com/dapr/dapr/pkg/version.version=edge -s -w" -o ./dist/darwin_amd64/release/injector ./cmd/injector/main.go;
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build  -ldflags="-X github.com/dapr/dapr/pkg/version.commit=v0.8.0-rc.2-96-g79a1f14 -X github.com/dapr/dapr/pkg/version.version=edge -s -w" -o ./dist/darwin_amd64/release/sentry ./cmd/sentry/main.go;

构建完成之后得到的文件:

$ ls -lh ./dist/darwin_amd64/release/
total 429128
-rwxr-xr-x  1 aoxiaojian  staff    89M Aug 13 17:19 daprd
-rwxr-xr-x  1 aoxiaojian  staff    33M Aug 13 17:20 injector
-rwxr-xr-x  1 aoxiaojian  staff    35M Aug 13 17:20 operator
-rwxr-xr-x  1 aoxiaojian  staff    12M Aug 13 17:19 placement
-rwxr-xr-x  1 aoxiaojian  staff    33M Aug 13 17:20 sentry

2 - Dapr的命令行参数

Dapr的命令行参数
name default value 可选值 说明
mode standalone standalone / kubernetes Runtime mode for Dapr
dapr-http-port 3500 HTTP port for Dapr API to listen on
dapr-grpc-port 50001 gRPC port for the Dapr API to listen on
dapr-internal-grpc-port "" gRPC port for the Dapr Internal API to listen on
如果不指定,则dapr会自动获取一个随机可用的空闲端口
app-port "" The port the application is listening on
如果不设置,则不能建立dapr和应用之间的 app channel
也就意味着dapr 无法发送请求给应用了
同时dapr也无法从应用读取配置: http://localhost:<app_port>/dapr/config
注意:app的地址在代码中写死 127.0.0.1
profile-port 7777 The port for the profile server
app-protocol http http / grpc Protocol for the application: grpc or http
components-path "" Path for components directory. If empty, components will not be loaded. Self-hosted mode only
仅在dapr mode为standalone时有效
config "" Path to config file, or name of a configuration object
被称为 global configuration
如果是kubernetes mode,读取k8s的配置
如果是standalone mode,读取配置文件
如果没有配置,则装载默认配置
app-id "" A unique ID for Dapr. Used for Service Discovery and state
control-plane-address "" Address for a Dapr control plane
仅在dapr mode为kubernetes时有效
sentry-address "" Address for the Sentry CA service
placement-host-address "" Address for the Dapr placement service
allowed-origins * Allowed HTTP origins
enable-profiling false True / false Enable profiling
version false True / false Prints the runtime version (然后dapr就会退出)
app-max-concurrency -1 Controls the concurrency level when forwarding requests to user code
enable-mtls false True / false Enables automatic mTLS for daprd to daprd communication channels

1.0 之后被弃用的flag:

name 说明
placement-address 改为 placement-host-address
如果同时设置,以 placement-host-address 为准
max-concurrency 改为 app-max-concurrency
如果同时设置,以 app-max-concurrency 为准
protocol 改为 app-protocol
如果同时设置,以 app-protocol 为准

-app-id hellogrpc -app-port 3000 -protocol grpc -dapr-http-port 3005 -dapr-grpc-port 52000 -placement-address localhost:50005 -components-path components