v0.7.0

Getting Started

Last updated

Build HakoRun from source, add the language runtimes, and upload and invoke your first function.

Prerequisites

Item Requirement
Go 1.25 or higher (go.mod)
OS Linux: bwrap, systemd-run, and a working systemd user session; macOS: the built-in sandbox-exec
Python python3
Node.js node and npm
TypeScript Global tsx, typescript, esbuild, plus a local esbuild in the project root
Redis Only when built with -tags redis

Install

git clone https://github.com/pardnchiu/HakoRun.git
cd HakoRun
npm install -g tsx typescript esbuild
npm install esbuild
make build          # ToriiDB by default, outputs bin/hako
make build redis    # Redis storage instead

HakoRun resolves internal/resource/wrapper.{py,js,ts} against the working directory at startup, so start the binary from the project root; a standalone binary from go install cannot find the wrappers.

On Linux, when node, tsc, esbuild, or python3 is missing at startup, HakoRun installs bubblewrap, nodejs, npm, and python3 through sudo and apt/dnf/pacman/apk. Auto-install does not cover tsc or esbuild; install them first, or every startup re-triggers the install.

Start

cp .env.example .env   # the Makefile loads .env
make run               # or ./bin/hako

The server listens on :8080 by default and shuts down gracefully within 5 seconds on SIGINT or SIGTERM.

First Function

Upload it, then call it by path:

curl --fail-with-body -X POST http://localhost:8080/upload \
  -H "Content-Type: application/json" \
  -d '{"path": "math/add", "language": "python", "code": "return event[\"a\"] + event[\"b\"]"}'

curl --fail-with-body -X POST http://localhost:8080/run/math/add \
  -H "Content-Type: application/json" \
  -d '{"input": "{\"a\": 3, \"b\": 5}"}'

The second request returns:

{ "data": 8, "type": "number" }
中文