Lightweight native process manager (Daemon & Cluster Supervisor) for MoonBit.
# Add as a MoonBit module from mooncakes.io
moon add wsafight/moond
# Or build the standalone native CLI binary from source
moon build --target native
# Binary: _build/native/debug/build/main/main.exeBIN=./_build/native/debug/build/main/main.exe
# Start 2 instances with custom env vars (auto-starts detached daemon)
$BIN start --name demo -i 2 -e PORT=8080 -- /bin/sh -c 'echo "worker $MOOND_INSTANCE_ID/$MOOND_INSTANCES"; sleep 60'
# List managed processes (table or JSON), live TUI monitor, & inspect details
$BIN ls
$BIN ls --json
$BIN monit
$BIN describe demo
# Rolling reload & dynamic scaling
$BIN reload demo --wait-ms 500
$BIN scale demo 4
# View, follow, or flush logs
$BIN logs demo -n 20
$BIN logs demo -f
$BIN flush demo
# Restart / stop / delete an app
$BIN restart demo
$BIN stop demo
$BIN delete demo
# Persist & restore state, or generate startup template
$BIN save
$BIN kill
$BIN resurrect
$BIN startup systemd # or launchd{
"apps": [
{
"name": "api",
"cmd": "./my-moonbit-api",
"args": ["--port", "8080"],
"cwd": ".",
"env": { "APP_ENV": "prod" },
"instances": 4,
"max_restarts": 15,
"restart_delay_ms": 1000,
"min_uptime_ms": 10000,
"max_log_bytes": 10485760
}
]
}# Start all apps or a single app with an environment profile
$BIN start moond.json --only api --env production
# Idempotent deploy: start missing apps, rolling-reload running ones (alias: startOrReload)
$BIN apply moond.json --env production
# Operate full lifecycle directly on config file
$BIN reload moond.json --only api
$BIN stop moond.json
$BIN delete moond.json| Variable | Default | Description |
|---|---|---|
| MOOND_HOME | ~/.moond | Stores token, state.json, daemon.pid, daemon.lock, and logs/ |
| MOOND_PORT | 19876 | Local HTTP control plane port (bound to 127.0.0.1) |
.
├── moon.mod # MoonBit module config (preferred_target = "native")
├── src/
│ ├── sys/ # Thin C FFI layer (setsid, getpid, kill_group, RSS & CPU, local time)
│ ├── protocol/ # Shared protocol types, paths, cron/memory/config parsers
│ ├── daemon/ # Supervisor, lifecycle, monitors, log rotation, watcher, HTTP API
│ ├── cli/ # CLI commands, config client, formatting, and monit TUI
│ └── main/ # Minimal single-binary executable entrypoint
├── examples/http-cluster/ # Multi-instance MoonBit HTTP server example
├── test_e2e.sh # End-to-end integration test suite
├── site/ # Astro website & docs (English default + /zh/, GitHub Pages)
└── .github/workflows/ # CI, Release, and GitHub Pages workflows# MoonBit unit tests
moon test --target native
# End-to-end integration tests
bash test_e2e.shcd site
pnpm install
pnpm run devInstall
Download zipLightweight native process manager (Daemon & Cluster Supervisor) for MoonBit.