[Ruby] Learn Digdag from the official Digdag documentation-Getting started

1 minute read

About #Digdag Digdag is an Open Source multi-cloud workflow engine. To put it simply, I thought it would be a tool to help with the flow of processing some work in order.

Target

Since there is no book about Digdag, I would like to organize it into Qiita while translating the documentation on the official Digdag website. http://docs.digdag.io/getting_started.html The documentation is in English. I think that there is a mistranslation because my purpose is to study. Today we’ll start with the Getting Started part. My final goal is to make a batch in Rails using Digdag’s Ruby.

table of contents

The contents are as follows. Getting started Architecture Concepts Workflow definition Scheduling workflow Operators Command reference Language API -Ruby Change the setting value for each environment with Digdag (RubyOnRails) Batch implementation in RubyOnRails environment using Digdag

Getting started

1. Download and install the latest version of Digdag

Digdag is an executable file. You can put a file in ~/bin using the ```curl

command.



$ curl -o ~/bin/digdag –create-dirs -L “https://dl.digdag.io/digdag-latest” $ chmod +x ~/bin/digdag $ echo’export PATH=”$HOME/bin:$PATH”’ » ~/.bashrc $ source ~/.bashrc

If you can execute ```digdag --help
#### **`, the environment setup is completed.`**

Those who use zsh should change ~/.bashrc to ```~/.zshrc

.



Windows

PowerShell -Command “& {[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::TLS12; mkdir -Force $env:USERPROFILE\bin; Invoke-WebRequest http://dl.digdag.io/digdag-latest .jar -OutFile $env:USERPROFILE\bin\digdag.bat}”


setx PATH “%PATH%;%USERPROFILE%\bin”


### 2. Try running the sample
The ```digdag init <dir>
#### **` command creates a sample Workflow.`**
$ digdag init mydag
$ cd mydag
$ digdag run

The following sample code (mydag.dig) is generated by the digdag init mydag command

mayday.dig


timezone: UTC

+setup:
  echo>: start ${session_time}

+disp_current_date:
  echo>: ${moment(session_time).utc().format('YYYY-MM-DD HH:mm:ss Z')}

+repeat:
  for_each>:
    order: [first, second, third]
    animal: [dog, cat]
  _do:
    echo>: ${order} ${animal}
  _parallel: true

+teardown:
  echo>: finish ${session_time}

digdag run workflow has been executed Execution result Screenshots 2020-07-09 13.19.57.png

Next time is Architecture