Getting Started
Build the native moond binary and launch your first multi-instance managed service.
Requirements
- MoonBit Toolchain: Latest version with
moonbitlang/core/asyncin the standard library (verified onmoon 0.1.20261126). - C Toolchain: Native C compiler for MoonBit Native backend and the thin
src/sysFFI shim (macOS / Linux).
Build Binary
Run from the repository root:
moon build --target native
The single native executable is generated at:
_build/native/debug/build/main/main.exe
You can symlink or copy it into your PATH as moond (for example /usr/local/bin/moond).
Launch Your First Managed App
On first start, moond automatically detaches and spawns the background daemon (moond daemon --detach) with lock-file protection and a 0600 Bearer token:
moond start --name demo -i 2 -e PORT=8080 -- \
/bin/sh -c 'echo "app=$MOOND_APP_NAME id=$MOOND_INSTANCE_ID/$MOOND_INSTANCES port=$PORT"; sleep 60'
Inspect running instances, live RSS memory, and JSON output:
moond ls
moond ls --json
moond describe demo
Follow Logs, Scale & Rolling Reload
# Show recent logs, follow incrementally, or filter a single instance
moond logs demo -n 20
moond logs demo -f
moond logs demo:0 -f
# Open live ANSI terminal monitor
moond monit
# Dynamically scale instances
moond scale demo 4
# Zero-downtime rolling reload
moond reload demo --wait 500
Built-in TCP Reverse Proxy (Cross-Platform Load Balancing)
On macOS or for services without SO_REUSEPORT, enable --proxy-port to expose a single front-end TCP port. moond automatically injects sequential PORT / MOOND_WORKER_PORT values into each worker and round-robins connections across healthy online instances:
moond start --name web -i 2 --proxy-port 8080 -- ./my-http-server
moond describe web
Persist & Restore Across Restarts
moond save
moond kill
moond resurrect
To generate a boot-time startup template for Linux systemd or macOS launchd:
moond startup systemd
moond startup launchd