run CLI command reference

Detailed information on the run CLI command

Description

Run Dapr and (optionally) your application side by side. A full list comparing daprd arguments, CLI arguments, and Kubernetes annotations can be found here.

Supported platforms

Usage

  1. dapr run [flags] [command]

Flags

NameEnvironment VariableDefaultDescription
—app-id, -aAPP_IDThe id for your application, used for service discovery. Cannot contain dots.
—app-max-concurrencyunlimited应用程序的并发级别;默认为无限制
—app-port, -pAPP_PORT应用程序正在侦听的端口
—app-protocol, -PhttpDapr 用于与应用程序通信的协议。 Valid values are: http, grpc, https (HTTP with TLS), grpcs (gRPC with TLS), h2c (HTTP/2 Cleartext)
—resources-path, -dLinux/Mac: $HOME/.dapr/components
Windows: %USERPROFILE%.dapr\components
The path for resources directory. If you’ve organized your resources into multiple folders (for example, components in one folder, resiliency policies in another), you can define multiple resource paths. See example below.
—app-channel-address127.0.0.1The network address the application listens on
—runtime-pathDapr 运行时安装路径
—config, -cLinux/Mac: $HOME/.dapr/config.yaml
Windows: %USERPROFILE%.dapr\config.yaml
Dapr configuration file
—dapr-grpc-port, -GDAPR_GRPC_PORT50001The gRPC port for Dapr to listen on
—dapr-internal-grpc-port, -I50002The gRPC port for the Dapr internal API to listen on. Set during development for apps experiencing temporary errors with service invocation failures due to mDNS caching, or configuring Dapr sidecars behind firewall. Can be any value greater than 1024 and must be different for each app.
—dapr-http-port, -HDAPR_HTTP_PORT3500The HTTP port for Dapr to listen on
—enable-profilingfalseEnable “pprof” profiling via an HTTP endpoint
—help, -hPrint the help message
—run-file, -fLinux/MacOS: $HOME/.dapr/dapr.yamlRun multiple applications at once using a Multi-App Run template file. Currently in alpha and only available in Linux/MacOS
—imageUse a custom Docker image. Format is repository/image for Docker Hub, or example.com/repository/image for a custom registry.
—log-levelinfo日志详细程度。 Valid values are: debug, info, warn, error, fatal, or panic
—enable-api-loggingfalse启用从应用程序到 Dapr 的所有 API 调用的日志记录
—metrics-portDAPR_METRICS_PORT9090Dapr 将 metrics 信息发送到的端口
—profile-port7777要监听的性能检测服务的端口
—enable-app-health-checkfalseEnable health checks for the application using the protocol defined with app-protocol
—app-health-check-pathPath used for health checks; HTTP only
—app-health-probe-interval以秒为单位探测应用程序健康状态的间隔
—app-health-probe-timeout应用健康探测的超时时间(以毫秒为单位)
—app-health-threshold应用被视为不健康之前的最大连续失败次数
—unix-domain-socket, -uUnix domain socket 目录挂载的路径。 如果指定了,与 Dapr sidecar 的通信将使用 unix domain sockets,与使用 TCP 端口相比,具有更低的延迟和更大的吞吐量。 在 Windows 操作系统上不可用。
—dapr-http-max-request-size4请求正文的最大尺寸,单位为MB。
—dapr-http-read-buffer-size4Http 请求头读取缓冲区的最大大小,单位为KB。 这也限制了 HTTP 标头的最大大小。 默认是4KB。
—kubernetes, -kRunning Dapr on Kubernetes, and used for Multi-App Run template files on Kubernetes.
—components-path, -dLinux/Mac: $HOME/.dapr/components
Windows: %USERPROFILE%.dapr\components
Deprecated in favor of —resources-path

示例

  1. # Run a .NET application
  2. dapr run --app-id myapp --app-port 5000 -- dotnet run
  3. # Run a .Net application with unix domain sockets
  4. dapr run --app-id myapp --app-port 5000 --unix-domain-socket /tmp -- dotnet run
  5. # Run a Java application
  6. dapr run --app-id myapp -- java -jar myapp.jar
  7. # Run a NodeJs application that listens to port 3000
  8. dapr run --app-id myapp --app-port 3000 -- node myapp.js
  9. # Run a Python application
  10. dapr run --app-id myapp -- python myapp.py
  11. # Run sidecar only
  12. dapr run --app-id myapp
  13. # Run a gRPC application written in Go (listening on port 3000)
  14. dapr run --app-id myapp --app-port 5000 --app-protocol grpc -- go run main.go
  15. # Run a NodeJs application that listens to port 3000 with API logging enabled
  16. dapr run --app-id myapp --app-port 3000 --enable-api-logging -- node myapp.js
  17. # Pass multiple resource paths
  18. dapr run --app-id myapp --resources-path path1 --resources-path path2
  19. # Run the multi-app run template file
  20. dapr run -f dapr.yaml
  21. # Run the multi-app run template file on Kubernetes
  22. dapr run -k -f dapr.yaml