Setting Up A Zenaton Project
TIP
If this is your first project, you probably want to follow the Hello World step-by-step example.
In your new project directory, you will need to
- have node.js (version >= 8.0) installed
- install the Zenaton node library
- add a
boot.js
file describing where to find tasks and workflow definitions - install and set up a Zenaton Agent
# Install Zenaton lib
Add a package.json
file with following dependencies:
{
"dependencies": {
"zenaton": "^0.7.3"
}
}
Then install dependencies:
npm install
# Add a Boot File
Tasks and workflows will be processed in the background by a Zenaton Agent (see below).
You need to provide the agent with a boot.js
file that describes tasks and workflow definitions:
Eg. if you have a unique MyTask
task and MyWorkflow
workflow, your ./boot.js
will be:
// load zenaton library
const { task, workflow } = require('zenaton');
// define "MyWorkflow" workflow
workflow("MyWorkflow", require("./src/myWorkflow"));
// define "MyTask" task
task("MyTask", require("./src/MyTask"));
WARNING
Do not forget to update this file, when adding task or workflow.
TIP
You can also regroup all task and workflow definition into some Tasks
and Workflows
directories, and name a workflow (or task) directly where you describe it. Then your boot.js
file can be written to load all files in those directories. This way you do not have to update it when creating a new task or workflow.
Look at documentation to see how to define workflows and tasks.
# Install Zenaton Agent
When developing locally, a Zenaton Agent needs to be installed on your computer.
This Agent will listen to the queues automaticaly deployed when we dispatch a task or a workflow. This Agent will both process tasks and decisions (a decision is the action to process your workflow file to decide what to do next).
To install the Zenaton Agent on your computer, type:
curl https://install.zenaton.com | sh
WARNING
Zenaton Agent is currently only available on mac and linux.
The Agent itself will be installed in
~/.zenaton
The CLI will be installed (usually) in/usr/local/bin
Once installed, you need to configure it to listen to your application:
zenaton listen \
--app_id=<app_id> \
--api_token=<api_token> \
--app_env=dev
--boot=boot.js
Your <app_id> and <api_token> are given in your API section
TIP
Define an .env
file to avoid having to type you creadential each time:
ZENATON_BOOT_PATH=./boot.js
ZENATON_APP_ID=<app_id>
ZENATON_API_TOKEN=<api_token>
ZENATON_APP_ENV=dev