v0.7.0

Getting Started

Last updated


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

Prerequisites


ItemRequirement
Go1.25 or higher (go.mod)
OSLinux: bwrap, systemd-run, and a working systemd user session; macOS: the built-in sandbox-exec
Pythonpython3
Node.jsnode and npm
TypeScriptGlobal tsx, typescript, esbuild, plus a local esbuild in the project root
RedisOnly when built with -tags redis

Install


  1. git clone https://github.com/pardnchiu/HakoRun.git
  2. cd HakoRun
  3. npm install -g tsx typescript esbuild
  4. npm install esbuild
  5. make build # ToriiDB by default, outputs bin/hako
  6. 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


  1. cp .env.example .env # the Makefile loads .env
  2. 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:
  1. curl --fail-with-body -X POST http://localhost:8080/upload \
  2. -H "Content-Type: application/json" \
  3. -d '{"path": "math/add", "language": "python", "code": "return event[\"a\"] + event[\"b\"]"}'
  4. curl --fail-with-body -X POST http://localhost:8080/run/math/add \
  5. -H "Content-Type: application/json" \
  6. -d '{"input": "{\"a\": 3, \"b\": 5}"}'

The second request returns:
  1. { "data": 8, "type": "number" }


中文