mirror of https://github.com/dapr/docs.git
pull template into another file
Signed-off-by: Hannah Hunter <hannahhunter@microsoft.com>
This commit is contained in:
parent
4f4536f06d
commit
b65db41d7e
|
@ -1,71 +0,0 @@
|
|||
---
|
||||
type: docs
|
||||
title: Run multiple applications with one command
|
||||
linkTitle: Multi-app Dapr Run
|
||||
weight: 2000
|
||||
description: Learn the scenarios around running multiple applications with one Dapr command
|
||||
---
|
||||
|
||||
{{% alert title="Note" color="primary" %}}
|
||||
Multi-app `dapr run` is currently a preview feature only supported in Linux/MacOS.
|
||||
{{% /alert %}}
|
||||
|
||||
Let's say you want to run several applications in local mode while being able to replication the production scenario. While in Kubernets mode, you'd be able to use helm/deployment YAML files, self-hosted mode required you to:
|
||||
|
||||
- Run multiple `dapr run` commands
|
||||
- Keep track of all ports opened
|
||||
- Remember the resources folders and configuration files that each application refers to
|
||||
- Recall all of the additional flags you used to tweak the `dapr run` command behavior (`--app-health-check-path`, `--dapr-grpc-port`, `--unix-domain-socket`, etc.)
|
||||
|
||||
With the Multi-app Dapr Run feature, you can easily start multiple Dapr applications in self-hosted mode using a single `dapr run -f` command.
|
||||
|
||||
## How does it work?
|
||||
|
||||
Currently, upon running [`dapr init`]({{< ref install-dapr-selfhost.md >}}), Dapr initializes in the `~/.dapr/` directory on Linux, where the default configurations and resources are stored.
|
||||
|
||||
For running multiple applications, `dapr init` will initialize the following `~/.dapr/` directory structure:
|
||||
|
||||
<img src="/images/multi-run-structure.png" width=800 style="padding-bottom:15px;">
|
||||
|
||||
When developing multiple applications, each **app directory** can have a `.dapr` folder, which contains a `config.yaml` file and a `resources` directory. If the `.dapr` directory is not present within the app directory, the default `~/.dapr/resources/` and `~/.dapr/config.yaml` locations are used.
|
||||
|
||||
> This change does not impact the `bin` folder, where the Dapr CLI looks for the `daprd` and `dashboard` binaries. That remains at `~/.dapr/bin/`.
|
||||
|
||||
### The `config.yaml` file
|
||||
|
||||
When you execute `dapr run -f`, Dapr parses the `config.yaml` file initialized with `dapr init`. The following example includes the configurations you can customize to your applications:
|
||||
|
||||
```yaml
|
||||
|
||||
version: 1
|
||||
common: (optional)
|
||||
resources_dir: ./app/components # any dapr resources to be shared across apps
|
||||
env: # any environment variable shared among apps
|
||||
- DEBUG: true
|
||||
apps:
|
||||
- app_id: webapp ## required
|
||||
app_dir: ./webapp/ ## required
|
||||
resources_dir: ./webapp/components # (optional) can be default by convention too, ignore if dir is not found.
|
||||
config_file: ./webapp/config.yaml # (optional) can be default by convention too, ignore if file is not found.
|
||||
app_protocol: HTTP
|
||||
app_port: 8080
|
||||
app_health_check_path: "/healthz" # All _ converted to - for all properties defined under daprd section
|
||||
command: ["python3" "app.py"]
|
||||
- app_id: backend
|
||||
app_dir: ./backend/
|
||||
app_protocol: GRPC
|
||||
app_port: 3000
|
||||
unix_domain_socket: "/tmp/test-socket"
|
||||
env:
|
||||
- DEBUG: false
|
||||
command: ["./backend"]
|
||||
```
|
||||
|
||||
### Precedence rules
|
||||
|
||||
|
||||
## Scenario
|
||||
|
||||
todo
|
||||
|
||||
## Next steps
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
type: docs
|
||||
title: "Multi-app support"
|
||||
linkTitle: "Multi-app support"
|
||||
weight: 300
|
||||
description: "Support for running multiple Dapr applications with one command"
|
||||
---
|
|
@ -0,0 +1,63 @@
|
|||
---
|
||||
type: docs
|
||||
title: Run multiple applications with one command
|
||||
linkTitle: Multi-app Dapr Run
|
||||
weight: 1000
|
||||
description: Learn the scenarios around running multiple applications with one Dapr command
|
||||
---
|
||||
|
||||
{{% alert title="Note" color="primary" %}}
|
||||
Multi-app `dapr run -f` is currently a preview feature only supported in Linux/MacOS.
|
||||
{{% /alert %}}
|
||||
|
||||
Let's say you want to run several applications locally to test them together, similar to a production scenario. With a local Kubernetes cluster, you'd be able to do this with helm/deployment YAML files. You'd also have to build them as containers and set up Kubernetes, which can add some complexity.
|
||||
|
||||
Instead, you simply want to run them as local executables in self-hosted mode. However, self-hosted mode requires you to:
|
||||
|
||||
- Run multiple `dapr run` commands
|
||||
- Keep track of all ports opened (you cannot have duplicate ports for different applications)- Remember the resources folders and configuration files that each application refers to
|
||||
- Recall all of the additional flags you used to tweak the `dapr run` command behavior (`--app-health-check-path`, `--dapr-grpc-port`, `--unix-domain-socket`, etc.)
|
||||
|
||||
With Multi-app Run, you can easily start multiple applications in self-hosted mode using a single `dapr run -f` command.
|
||||
|
||||
## Multi-app template file
|
||||
|
||||
When you execute `dapr run -f`, Dapr parses the multi-app template file initialized with `dapr init`. By default, this template file is called `dapr.yaml`.
|
||||
|
||||
You can customize the template file by executing `dapr run -f ./<your-preferred-file-name>.yaml`.
|
||||
|
||||
The following `dapr.yaml` example includes some of the configurations you can customize to your applications. For a more in-depth example and explanation of variables, see [Multi-app template]({{< ref multi-app-template.md >}}).
|
||||
|
||||
```yaml
|
||||
version: 1
|
||||
apps:
|
||||
- appDirPath: ../../../apps/processor/
|
||||
appPort: 9081
|
||||
daprHTTPPort: 3510
|
||||
command: ["go","run", "app.go"]
|
||||
- appID: emit-metrics
|
||||
appDirPath: ../../../apps/emit-metrics/
|
||||
daprHTTPPort: 3511
|
||||
env:
|
||||
DAPR_HOST_ADD: localhost
|
||||
command: ["go","run", "app.go"]
|
||||
```
|
||||
|
||||
|
||||
## How does it work?
|
||||
|
||||
When running [`dapr init`]({{< ref install-dapr-selfhost.md >}}), this initializes a directory where the default configurations and resources are stored.
|
||||
|
||||
For running multiple applications, `dapr init` will initialize the following `~/.dapr/` directory structure:
|
||||
|
||||
<img src="/images/multi-run-structure.png" width=800 style="padding-bottom:15px;">
|
||||
|
||||
When developing multiple applications, each **app directory** can have a `.dapr` folder, which contains a `config.yaml` file and a `resources` directory. If the `.dapr` directory is not present within the app directory, the default `~/.dapr/resources/` and `~/.dapr/config.yaml` locations are used.
|
||||
|
||||
> This change does not impact the `bin` folder, where the Dapr CLI looks for the `daprd` and `dashboard` binaries. That remains at `~/.dapr/bin/`.
|
||||
|
||||
|
||||
### Precedence rules
|
||||
|
||||
|
||||
## Next steps
|
|
@ -0,0 +1,90 @@
|
|||
---
|
||||
type: docs
|
||||
title: Multi-app template file
|
||||
linkTitle: Multi-app template
|
||||
weight: 2000
|
||||
description: Unpack the multi-app template file and its variables
|
||||
---
|
||||
|
||||
{{% alert title="Note" color="primary" %}}
|
||||
Multi-app `dapr run -f` is currently a preview feature only supported in Linux/MacOS.
|
||||
{{% /alert %}}
|
||||
|
||||
The multi-app template file is a single YAML configuration file that you can use to configure multiple applications alongside a Dapr sidecar. Execute the following command for Dapr to parse the multi-app template file, named `dapr.yaml` by default:
|
||||
|
||||
```cmd
|
||||
dapr run -f
|
||||
```
|
||||
|
||||
To name the multi-app template file something other than `dapr.yaml`, run:
|
||||
|
||||
```cmd
|
||||
dapr run -f ./<your-preferred-file-name>.yaml
|
||||
```
|
||||
|
||||
The multi-app template file can include any of the following parameters.
|
||||
|
||||
```yaml
|
||||
version: 1
|
||||
common: # optional section for variables shared across apps
|
||||
resourcesPath: ./app/components # any dapr resources to be shared across apps
|
||||
env: # any environment variable shared across apps
|
||||
- DEBUG: true
|
||||
apps:
|
||||
- appID: webapp # required
|
||||
appDirPath: ./webapp/ # required
|
||||
resourcesPath: ./webapp/components # (optional) can be default by convention
|
||||
configFilePath: ./webapp/config.yaml # (optional) can be default by convention too, ignore if file is not found.
|
||||
appProtocol: HTTP
|
||||
appPort: 8080
|
||||
appHealthCheckPath: "/healthz" # All _ converted to - for all properties defined under daprd section
|
||||
command: ["python3" "app.py"]
|
||||
- appID: backend
|
||||
appDirPath: ./backend/
|
||||
appProtocol: GRPC
|
||||
appPort: 3000
|
||||
unixDomainSocket: "/tmp/test-socket"
|
||||
env:
|
||||
- DEBUG: false
|
||||
command: ["./backend"]
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
|
||||
| Parameter | Required | Details | Example |
|
||||
|--------------------------|:--------:|--------|---------|
|
||||
| `appID` | Y | Your application's app ID | `webapp`, `backend` |
|
||||
| `appDirPath` | Y | Path to the your application | `./webapp/`, `./backend/` |
|
||||
| `resourcesPath` | N | Path to your Dapr resources. Can be default by convention; ignore if directory isn't found | `./app/components`, `./webapp/components` |
|
||||
| `configFilePath` | N | Path to your application's configuration file | `./webapp/config.yaml` |
|
||||
| `appProtocol` | N | Application protocol | `HTTP`, `GRPC` |
|
||||
| `appPort` | N | Designated port for your application | `8080`, `3000` |
|
||||
| `daprHTTPPort` | N | Dapr HTTP port | |
|
||||
| `daprGRPCPort` | N | Dapr GRPC port | |
|
||||
| `daprInternalGRPCPort` | N | | |
|
||||
| `metricsPort` | N | | |
|
||||
| `unixDomainSocket` | N | Path to the Unix Domain Socket | `/tmp/test-socket` |
|
||||
| `profilePort` | N | | |
|
||||
| `enableProfiling` | N | | |
|
||||
| `apiListenAddresses` | N | Dapr API listen addresses | |
|
||||
| `logLevel` | N | | |
|
||||
| `appMaxConcurrency` | N | | |
|
||||
| `placementHostAddress` | N | | |
|
||||
| `appSSL` | N | | |
|
||||
| `daprHTTPMaxRequestSize` | N | | |
|
||||
| `daprHTTPReadBufferSize` | N | | |
|
||||
| `enableAppHealthCheck` | N | Enable the app health check on the application | `true`, `false` |
|
||||
| `appHealthCheckPath` | N | Path to the health check file | `/healthz` |
|
||||
| `appHealthProbeInterval` | N | App health check interval time range | |
|
||||
| `appHealthProbeTimeout` | N | When the app health check will timeout | |
|
||||
| `appHealthThreshold` | N | | |
|
||||
| `enableApiLogging` | N | | |
|
||||
| `daprPath` | N | Dapr install path | |
|
||||
| `env` | N | Map to environment variable; environment variables applied per application will overwrite environment variables shared across applications | `DEBUG`, `DAPR_HOST_ADD` |
|
||||
|
||||
## Scenario
|
||||
|
||||
todo
|
||||
|
||||
## Next steps
|
|
@ -35,6 +35,7 @@ dapr run [flags] [command]
|
|||
| `--dapr-http-port` | `DAPR_HTTP_PORT` | `3500` | The HTTP port for Dapr to listen on |
|
||||
| `--enable-profiling` | | `false` | Enable "pprof" profiling via an HTTP endpoint |
|
||||
| `--help`, `-h` | | | Print the help message |
|
||||
| `--run-file`, `-f` | | Linux/Mac: `$HOME/.dapr/dapr.yaml` | Run multiple applications at once via the multi-app template file |
|
||||
| `--image` | | | Use a custom Docker image. Format is `repository/image` for Docker Hub, or `example.com/repository/image` for a custom registry. |
|
||||
| `--log-level` | | `info` | The log verbosity. Valid values are: `debug`, `info`, `warn`, `error`, `fatal`, or `panic` |
|
||||
| `--enable-api-logging` | | `false` | Enable the logging of all API calls from application to Dapr |
|
||||
|
|
Loading…
Reference in New Issue