docs: update README for the working binary
CI / test (push) Canceled after 0s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Daniel SamsonandClaude Sonnet 5.5 committed 2026-10-17 13:53:56 +01:00
1 parent b022dcf32b
commit 93b5370dbf
1 file changed
+89 -19
+89 -19
View File
@@ -1,9 +1,10 @@
# Zag Job Daemon (Cross-Platform) # Zag Job Daemon (Cross-Platform)
> **Status:** early development. Zag is the [Zig](https://ziglang.org) port of > Zag is the [Zig](https://ziglang.org) port of
> [barn](https://gitea.samson.media/samson-media/barn), the Java job daemon. The goal is > [barn](https://gitea.samson.media/samson-media/barn), the Java job daemon. It keeps barn's
> CLI and on-disk compatibility with barn so the two can be swapped without > CLI, JSON/XML output and job directory layout so clients can switch by changing the binary
> changing clients. > name, and fixes the places where barn's behaviour did not match its documentation (see
> [Migration from barn](#migration-from-barn)).
A **cross-platform service** for managing long-running jobs that involve A **cross-platform service** for managing long-running jobs that involve
downloading and uploading media via WebDAV, using FFmpeg to analyse and transcode video, with strong guarantees around durability, downloading and uploading media via WebDAV, using FFmpeg to analyse and transcode video, with strong guarantees around durability,
@@ -52,14 +53,54 @@ a low idle memory footprint, and easy cross-compilation to every supported platf
--- ---
## Installation
### Linux / macOS
The installer downloads the latest release, installs the binary and registers a service
(systemd on Linux, launchd on macOS). The repository is private, so provide an access token:
```bash
export ZAG_TOKEN=<gitea access token>
curl -fsSL -H "Authorization: token $ZAG_TOKEN" \
https://gitea.samson.media/samson-media/zag/raw/branch/main/install.sh | sh
```
`ZAG_VERSION`, `ZAG_PREFIX` and `ZAG_NO_SERVICE=1` tune the install; see the header of `install.sh`.
### Manual
Download `zag-linux-x64`, `zag-linux-arm64`, `zag-macos-arm64` or `zag-macos-x64` from the
[releases page](https://gitea.samson.media/samson-media/zag/releases), check it against
`SHA256SUMS`, and put it on your `PATH`:
```bash
chmod +x zag-linux-x64 && sudo mv zag-linux-x64 /usr/local/bin/zag
zag --version
```
The binaries are static and need no runtime. Windows is not supported yet.
### Setting up the service
```bash
sudo zag service install # system-wide (as root); without sudo it installs for your user
zag service start
zag service status
```
Once installed, `zag service start|stop|restart` go through systemd/launchd. Without
installing, `zag service start` runs a detached daemon of its own.
## Building ## Building
Requires Zig 0.16.0 or newer. Requires Zig 0.16.0 or newer. Linux builds default to musl (a static binary).
```bash ```bash
zig build # build to zig-out/bin/zag zig build # build to zig-out/bin/zag
zig build test # run tests zig build test # unit tests
zig build -Doptimize=ReleaseSafe # release build zig build e2e # end-to-end smoke test against the built binary
zig build -Doptimize=ReleaseSafe -Dstrip=true # release build (~1 MB)
``` ```
Cross-compile with `-Dtarget`, for example: Cross-compile with `-Dtarget`, for example:
@@ -72,19 +113,31 @@ zig build -Doptimize=ReleaseSafe -Dtarget=aarch64-linux
--- ---
## Global options
| Option | Description |
|--------|-------------|
| `-o, --output {human\|json\|xml}` | Output format (default `human`) |
| `--config <file>` | Configuration file to merge on top of the system and user files |
| `--offline` | Run without the service: same code, in this process (`zag run --offline` executes the job and prints its final state) |
| `--barn-dir <dir>` | Data directory, overriding `storage.base_dir` (also relocates the socket) |
## Zag command ## Zag command
This project creates a simple CLI commandlet with sub-commands. This project creates a simple CLI commandlet with sub-commands.
- `zag service {start|stop|restart|reload|status|logs}` - manages the zag service - `zag service {start|stop|restart|reload|status|logs|install|uninstall}` - manages the zag service
- `zag run {command}` - starts job - `zag run {command}` - starts job
- `zag status` - gets the status of all jobs running - `zag status` - gets the status of all jobs running
- `zag describe {jobId}` - collects all the info from /tmp and display it - `zag describe {jobId}` - collects all the info from /tmp and display it
- `zag usage {jobId}` - shows resource usage (CPU, memory, disk) for a job - `zag usage {jobId}` - shows resource usage (CPU, memory, disk, GPU) for a job
- `zag kill {jobId}` - kills a job - `zag kill {jobId}` - kills a job
- `zag clean` - performs clean up - `zag clean` - performs clean up
- `zag config install` - installs default configuration files - `zag config install` - installs default configuration files
- `zag config show` - shows effective configuration - `zag config show` - shows effective configuration
- `zag config validate --file <path>` - checks a configuration file
- `zag config init` - writes a default user configuration file
- `zag autocompletion {--bash|--zsh}` - prints a shell completion script
zag is just one binary for both the service and the client. The client uses IPC to communicate with the service. zag is just one binary for both the service and the client. The client uses IPC to communicate with the service.
@@ -191,19 +244,36 @@ zag run --load-level=high -- curl -O https://example.com/file.zip
| Area | Barn | Zag | | Area | Barn | Zag |
|------|------|-----| |------|------|-----|
| Language | Java 21 | Zig | | Language | Java 21 (GraalVM native image) | Zig, static binary of about 1 MB |
| Binary | `barn` | `zag` | | Binary | `barn` | `zag` |
| Data dir | `/tmp/barn` | `/tmp/zag` | | Data dir | `/tmp/barn` | `/tmp/zag` |
| Config dir | `/etc/barn/` | `/etc/zag/` | | Config | `/etc/barn/barn.conf`, `~/.config/barn/barn.conf` | `/etc/zag/zag.conf`, `~/.config/zag/zag.conf` |
| Environment overrides | `BARN_<SECTION>_<KEY>` | `ZAG_<SECTION>_<KEY>` (`ZAG_LOAD_LEVELS_MAX_HIGH_JOBS` works) |
| Socket | `<base>/barn.sock` | `<base>/zag.sock` (mode 0600) |
The CLI surface, `--output={json|xml}` formats, job states, load levels and retry The CLI surface, `--output={json|xml}` formats, job states, load levels and the on-disk job
semantics are intended to match barn exactly. Anything that differs will be documented here. layout match barn. Where barn's code disagreed with its own documentation, zag follows the
documentation:
- `zag clean` behaves the same offline and through the service: with none of `--all`,
`--older-than` or `--job-id` it removes nothing.
- `kill` ends the job as `canceled` without racing the runner, and also cancels *queued* jobs.
- A failed job is **actually retried** (`--max-retries`, `--retry-delay`, `retry_on_exit_codes`,
exponential backoff with jitter); barn only retried jobs orphaned by a crash.
- `--timeout` and `default_timeout_seconds` are enforced (symbolic exit code `timeout`).
- `service reload` re-reads the configuration (also on SIGHUP) instead of doing nothing.
- `heartbeat_interval_seconds` is honoured, and `storage.base_dir` / `service.ipc_socket` are
used consistently by the daemon *and* the CLI.
- Jobs run in their own process group, so `kill` and `service stop --force` take down the whole
process tree. Job directories are created and deleted atomically.
- Without `config install`, the built-in `.load` lists still classify `ffmpeg` as HIGH and
`curl` as LOW.
- `config show` calls the load-limit section `load_levels`, matching the config file.
Not implemented yet: Windows, `max_disk_usage_gb`, `preserve_work_dir`, auto-update.
## Project Layout ## Project Layout
``` See [AGENTS.md](AGENTS.md) for the module map. In short: `src/cli*.zig` is the command line,
build.zig build script `src/service.zig` the daemon core, `src/scheduler.zig` / `src/runner.zig` run jobs,
build.zig.zon package manifest `src/repository.zig` persists them, `src/ipc.zig` is the socket protocol.
src/main.zig CLI entry point
src/root.zig library root
```