Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
yottahmd committed Nov 20, 2022
1 parent db1e8f4 commit 9f2b043
Showing 1 changed file with 84 additions and 90 deletions.
174 changes: 84 additions & 90 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,14 @@ It runs <a href="https://en.wikipedia.org/wiki/Directed_acyclic_graph">DAGs (Dir
- [Parameters](#parameters)
- [Command Substitution](#command-substitution)
- [Conditional Logic](#conditional-logic)
- [Run Docker Image](#run-docker-image)
- [Make HTTP Request](#make-http-request)
- [Run Command via SSH](#run-command-via-ssh)
- [Output](#output)
- [Stdout and Stderr Redirection](#stdout-and-stderr-redirection)
- [Lifecycle Hooks](#lifecycle-hooks)
- [Repeating Task](#repeating-task)
- [Other Available Fields](#other-available-fields)
- [Executor](#executor)
- [Running Docker Image](#running-docker-image)
- [Executing HTTP Request](#executing-http-request)
- [Executing Remote Command via SSH](#executing-remote-command-via-ssh)
- [Admin Configuration](#admin-configuration)
- [Environment Variable](#environment-variable)
- [Sending email notifications](#sending-email-notifications)
Expand Down Expand Up @@ -326,6 +325,87 @@ steps:
skipped: true
```
### Run Docker Image
The Docker Executor allows us to run any docker image. In the below example, it runs [Deno's docker image](https://hub.docker.com/r/denoland/deno) and prints 'Hello World'.
```yaml
steps:
- name: deno_hello_world
executor:
type: docker
config:
image: "denoland/deno:1.10.3"
autoRemove: true
command: run https://examples.deno.land/hello-world.ts
```
Example Log output:
![docker](./examples/images/docker.png)
You can pass additional options for Docker `container` and `host`:

```yaml
steps:
- name: deno_hello_world
executor:
type: docker
config:
image: "denoland/deno:1.10.3"
container:
volumes:
/app:/app:
env:
- FOO=BAR
host:
autoRemove: true
command: run https://examples.deno.land/hello-world.ts
```

See Docker's API documentation for all available options.
- For `container`, see [ContainerConfig](https://pkg.go.dev/github.com/docker/docker/api/types/container#Config).
- For `host`, see [HostConfig](https://pkg.go.dev/github.com/docker/docker/api/types/container#HostConfig).

### Make HTTP Request

The HTTP Executor allows us to make an arbitrary HTTP request.

```yaml
steps:
- name: send POST request
executor: http
command: POST https://foo.bar.com
script: |
{
"timeout": 10,
"headers": {
"Authorization": "Bearer $TOKEN"
},
"query": {
"key": "value"
},
"body": "post body"
}
```

### Run Command via SSH

The SSH Executor allows us to execute arbitrary command on a remote host.

```yaml
steps:
- name: step1
executor:
type: ssh
config:
user: dagu
ip: XXX.XXX.XXX.XXX
port: 22
key: /Users/dagu/.ssh/private.pem
command: /usr/sbin/ifconfig
```

### Output

`output` field can be used to set a environment variable with standard output. Leading and trailing space will be trimmed automatically. The environment variables can be used in subsequent steps.
Expand Down Expand Up @@ -449,92 +529,6 @@ steps:
The global configuration file `~/.dagu/config.yaml` is useful to gather common settings, such as `logDir` or `env`.

## Executor

Executor is a different way of executing a Step; Executor can be set in the `executor` field.

### Running Docker Image

The Docker Executor allows us to run arbitrary docker image. The below example runs [Deno's docker image](https://hub.docker.com/r/denoland/deno) and prints 'Hello World'.


```yaml
steps:
- name: deno_hello_world
executor:
type: docker
config:
image: "denoland/deno:1.10.3"
autoRemove: true
command: run https://examples.deno.land/hello-world.ts
```

Example Log output:

![docker](./examples/images/docker.png)

You can pass additionl options for Docker `container` and `host`:

```yaml
steps:
- name: deno_hello_world
executor:
type: docker
config:
image: "denoland/deno:1.10.3"
container:
volumes:
/app:/app:
env:
- FOO=BAR
host:
autoRemove: true
command: run https://examples.deno.land/hello-world.ts
```

See Docker's API document for all available options.
- For `container`, see [ContainerConfig](https://pkg.go.dev/github.com/docker/docker/api/types/container#Config).
- For `host`, see [HostConfig](https://pkg.go.dev/github.com/docker/docker/api/types/container#HostConfig).

### Executing HTTP Request

The HTTP Executor allows us to send arbitrary HTTP requests.

```yaml
steps:
- name: send POST request
executor: http
command: POST https://foo.bar.com
script: |
{
"timeout": 10,
"headers": {
"Authorization": "Bearer $TOKEN"
},
"query": {
"key": "value"
},
"body": "post body"
}
```

### Executing Remote Command via SSH

The SSH Executor allows us to execute arbitrary command on a remote host.

```yaml
steps:
- name: step1
executor:
type: ssh
config:
user: dagu
ip: XXX.XXX.XXX.XXX
port: 22
key: /Users/dagu/.ssh/private.pem
command: /usr/sbin/ifconfig
```

## Admin Configuration

To configure dagu, please create the config file (default path: `~/.dagu/admin.yaml`). All fields are optional.
Expand Down

0 comments on commit 9f2b043

Please sign in to comment.