logo
0
0
WeChat Login
feat: add Zig implementation of moni HTTP server

moni (Zig)

Lightweight HTTP monitoring server implemented in Zig, single-threaded event loop using epoll.

Version: 0.0.1

Build

Requires Zig 0.13.0+.

zig build-exe moni.zig -O ReleaseSafe -target native-linux-gnu

Run

./moni # Start on port 8080 ./moni -p 9090 # Custom port ./moni -f /tmp/flag # Set file path via CLI MONI_PATH=/tmp/flag ./moni # Set file path via env ./moni -v # Enable verbose logging ./moni -h # Show help

Endpoints

PathDescriptionResponse
/versionServer version0.0.1
/hostnameMachine hostnamee.g. myserver
Any otherFile existence check1 (exists) / 0 (not exists) / 500 (not configured)

Options

FlagDescriptionDefault
-p PORTListen port8080
-f PATHFile path to check
-vVerbose request/response loggingoff
-hShow help

File path can also be set via MONI_PATH environment variable. CLI -f takes priority.

Architecture

  • I/O Model: epoll with edge-triggered mode
  • Concurrency: Single-threaded event loop
  • Dependencies: None (Zig standard library only)
  • Signals: SIGINT/SIGTERM for graceful shutdown, SIGPIPE ignored
  • URL: Supports percent-encoded paths via URL decoding

Example

# Terminal 1 MONI_PATH=/tmp/flag ./moni -v # Terminal 2 curl http://localhost:8080/version # 0.0.1 curl http://localhost:8080/hostname # myserver touch /tmp/flag curl http://localhost:8080/check # 1 rm /tmp/flag curl http://localhost:8080/check # 0