Running Your First Workflow
This tutorial assumes that you've already
installed the ak
CLI tool, and
started a local server.
The ak
CLI tool functions both as a client and as a server.
In this tutorial, you will create a basic workflow that starts when AutoKitteh receives an HTTP request, and prints a simple message to AutoKitteh's session log.
Download the Samples
An AutoKitteh project is a collection of settings and code that implements workflows.
Download the AutoKitteh samples repository, which contains various project directories:
git clone https://github.com/autokitteh/samples.git
Alternatively, download and extract the repository's zip archive file:
https://github.com/autokitteh/samples/archive/refs/heads/main.zip
Create and Deploy a Project
In this tutorial, you will use an existing project from the samples repository that you downloaded in the previous step.
Run these commands:
cd samples
ak deploy --manifest quickstart/autokitteh.yaml --file quickstart/program.star
Under the hood
The ak deploy
command does the following:
- Create a new Autokitteh project
- Apply the project settings from the sample's YAML manifest file
- Build (i.e. compile and package a snapshot of) the sample's source code
- Deploy this build
- Activate this deployment
Expected output:
[plan] project "quickstart_project": not found, will create
[plan] connection "quickstart_project/http_conn": not found, will create
[plan] trigger "quickstart_project/default:quickstart_project/http/get": not found, will create
[exec] create_project "quickstart_project": created "prj_aaaaaaaaaaaaaaaaaaaaaaaaaa"
[exec] create_connection "quickstart_project/http_conn": created "con_cccccccccccccccccccccccccc"
[exec] create_trigger "quickstart_project/default:quickstart_project/http_conn/get": created "trg_dddddddddddddddddddddddddd"
[exec] create_build: created "bld_eeeeeeeeeeeeeeeeeeeeeeeeee"
[exec] create_deployment: created "dep_ffffffffffffffffffffffffff"
[exec] activate_deployment: activated
That's it! The project is now waiting for trigger events in order to start runtime sessions that run workflows.
Trigger the Deployment
Run this command:
curl -v http://localhost:9980/http/quickstart_project/trigger_path
Explanation
localhost:9980
is the address of the local Autokitteh server that you
started (with the default port number).
The path /http/quickstart_project/trigger_path
is a trigger defined in the
YAML manifest file:
- Connection type:
http
- Project name:
quickstart_project
- Specific trigger:
trigger_path
See the Results
Run this command to check that a runtime session has indeed started and ended:
ak session list -J
Expected output:
{
"session_id": "ses_wwwwwwwwwwwwwwwwwwwwwwwwww",
"event_id": "evt_xxxxxxxxxxxxxxxxxxxxxxxxxx",
"deployment_id": "dep_ffffffffffffffffffffffffff",
"build_id": "bld_eeeeeeeeeeeeeeeeeeeeeeeeee",
"env_id": "env_bbbbbbbbbbbbbbbbbbbbbbbbbb",
"entrypoint": {
"path": "program.star",
"name": "on_http_get"
},
"created_at": "2024-03-22T00:12:34.123456Z",
"updated_at": "2024-03-22T00:12:35.123456Z",
"state": "SESSION_STATE_TYPE_COMPLETED"
}
Now, run this command:
ak session log --prints-only
This command outputs all the print
messages in the latest session's log:
[2024-03-22T00:12:34.123456 +0000 UTC] Received GET request
Next Steps
To continue this tutorial, go to the resilience demo tutorial.