1. Create a project
- Install runnerty
npm i -g runnerty
- Let's create the project, execute this command in your terminal.
runnerty new my-first-runnerty-project
The following contents will be created in your current directory.
└── my-first-runnerty-project/
├── config.json
├── package.json
├── plan.json
└── chains/
└── chain-one.json
- Run
runnerty
orrunnerty run
.
🎉🎉 Congratulations, you have just made your first Runnerty project!
You can know connect to Runnerty Platform.
This workflow executes an echo
command every minute leaving the response in a log file. The terminal where we run the project is also notified of the beginning and end of the chain.
Details of the example project
package.json
We find this dependencies:
{
"dependencies": {
"@runnerty/executor-shell": "^3.1.0",
"@runnerty/notifier-console": "^3.0.3",
"@runnerty/trigger-schedule": "^3.0.3"
}
}
trigger-schedule
: Trigger for planned executions using expressions CRON (more about triggers).executor-shell
: Executor shell launches a command in a new process and we can pass that command any arguments (more about executors).notifier-console
: Notifier used to monitor the events that the chain (more about chains).
You can find more plugins available here.
config.json
We find this:
{
"triggers": [
{
"id": "schedule_default",
"type": "@runnerty-trigger-schedule"
}
],
"executors": [
{
"id": "shell_default",
"type": "@runnerty-executor-shell"
}
],
"notifiers": [
{
"id": "console_default",
"type": "@runnerty-notifier-console"
}
],
"global_values": [
{
"WORKDIR": {
"PATH": ".",
"BATCH": "batch",
"SQL": "sql"
}
},
{
"LOGS": {
"PATH": "./logs"
}
}
],
"defaults": {
"chain": {
"notifications": {
"on_start": [
{
"id": "console_default",
"message": "@GETDATE('YYYY-MM-DD HH:mm:ss') START OF THE CHAIN: @GV(CHAIN_ID)"
}
],
"on_end": [
{
"id": "console_default",
"message": "@GETDATE('YYYY-MM-DD HH:mm:ss') END OF THE CHAIN: @GV(CHAIN_ID)"
}
],
"on_fail": [
{
"id": "console_default",
"message": "@GETDATE('YYYY-MM-DD HH:mm:ss') FAIL OF THE CHAIN: @GV(CHAIN_ID)",
"mode": "error"
}
]
}
},
"process": {
"notifications": {
"on_start": [
{
"id": "console_default",
"message": "@GETDATE('YYYY-MM-DD HH:mm:ss') START: PROCESS @GV(PROCESS_ID)"
}
],
"on_fail": [
{
"id": "console_default",
"message": "@GETDATE('YYYY-MM-DD HH:mm:ss') ERROR: PROCESS @GV(PROCESS_ID): @GV(PROCESS_EXEC_ERR_OUTPUT)",
"mode": "error"
}
],
"on_end": [
{
"id": "console_default",
"message": "@GETDATE('YYYY-MM-DD HH:mm:ss') END: PROCESS @GV(PROCESS_ID): @GV(PROCESS_EXEC_MSG_OUTPUT)"
}
]
},
"output": [
{
"file_name": "@GV(LOGS_PATH)/@GETVALUE(PROCESS_ID).log",
"write": [
"EXECUTION @GV(PROCESS_ID) - AT @GETDATE('YYYY-MM-DD HH:mm:ss')\n @GV(PROCESS_EXEC_ERR_OUTPUT) @GV(PROCESS_EXEC_MSG_OUTPUT)"
],
"concat": true,
"maxsize": "10mb"
}
]
}
}
In the examples shown here, a couple of functions (@GV
and @GETDATE
) from Runnerty's interpreter are used.
Learn more about the available functions here.
Let's focus on the three properties that include triggers
, executors
, and notifiers
. Each plugin is assigned an identifier (id), type, which identifies the plugin and its configuration.
{
"executors": [
{
"id": "mysql_default",
"type": "@runnerty-executor-mysql",
"user": "mysqlusr",
"password": "mysqlpass",
"database": "MYDB",
"host": "myhost.com",
"port": "3306"
}
]
}
plan.json
{
"$schema": "https://raw.githubusercontent.com/runnerty/schemas/master/schemas/3.2/plan.json",
"chains": [{ "chain_path": "./chains/chain-one.json" }]
}
chains
├── chain
| └── processes
| ├── process
| └── ...
├── chain
| └── processes
| ├── process
| └── ...
└── ...
In the plan we can define the chain itself or instead, for a better organization, we can define the path (chain_path) to a json where to define the chain, as it is done in this guide.
For this case, we have a single chain with a single process:
chains
└── CHAIN_ONE
└── processes
└── PROCESS_ONE
chain-one.json
{
"$schema": "https://raw.githubusercontent.com/runnerty/schemas/master/schemas/3.2/chain.json",
"id": "CHAIN_ONE",
"name": "Chain one sample",
"triggers": [
{
"id": "schedule_default",
"schedule_interval": "*/1 * * * *"
}
],
"processes": [
{
"id": "PROCESS_ONE",
"name": "Proccess One",
"exec": {
"id": "shell_default",
"command": "echo hello world!"
}
}
]
}