Archived
docs: use cross-platform barn commands only
Remove shell-specific commands (tail, watch, grep) in favor of barn describe --logs for cross-platform compatibility. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
37731a6b54
commit
e9bb8ef1bc
1 file changed
+26
-42
+26
-42
@@ -154,49 +154,31 @@ Example error response:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Complete Example Script
|
### Polling Example
|
||||||
|
|
||||||
|
Poll until job completes:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
#!/bin/bash
|
# Submit job and get ID
|
||||||
set -e
|
barn run --output=json -- ffmpeg -y -progress pipe:1 -threads 0 -i input.mkv -c:v libx264 output.mp4
|
||||||
|
# Returns: {"id": "job-abc123", "state": "QUEUED", ...}
|
||||||
|
|
||||||
INPUT="/path/to/input.mkv"
|
# Poll for status
|
||||||
OUTPUT="/path/to/output.mp4"
|
barn describe job-abc123 --output=json
|
||||||
|
# Check "state" field: "queued", "running", "succeeded", "failed"
|
||||||
|
|
||||||
# Submit job
|
# Get progress while running
|
||||||
RESPONSE=$(barn run --output=json -- ffmpeg -y -progress pipe:1 -threads 0 -i "$INPUT" -c:v libx264 "$OUTPUT")
|
barn describe job-abc123 --logs --output=json
|
||||||
JOB_ID=$(echo "$RESPONSE" | jq -r '.id')
|
# Parse "logs.stdout" for progress fields (frame=, speed=, progress=)
|
||||||
echo "Started job: $JOB_ID"
|
|
||||||
|
|
||||||
# Poll until complete
|
|
||||||
while true; do
|
|
||||||
STATUS=$(barn describe "$JOB_ID" --output=json)
|
|
||||||
STATE=$(echo "$STATUS" | jq -r '.state')
|
|
||||||
|
|
||||||
case "$STATE" in
|
|
||||||
"queued"|"running")
|
|
||||||
# Get progress
|
|
||||||
PROGRESS=$(barn describe "$JOB_ID" --logs --output=json | jq -r '.logs.stdout' | grep -o 'speed=[0-9.]*x' | tail -1)
|
|
||||||
echo "Status: $STATE $PROGRESS"
|
|
||||||
sleep 2
|
|
||||||
;;
|
|
||||||
"succeeded")
|
|
||||||
echo "Job completed successfully"
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
"failed")
|
|
||||||
ERROR=$(echo "$STATUS" | jq -r '.error')
|
|
||||||
echo "Job failed: $ERROR"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Job ended with state: $STATE"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The polling loop logic:
|
||||||
|
1. Call `barn describe <job-id> --output=json`
|
||||||
|
2. Check `state` field
|
||||||
|
3. If `queued` or `running`, sleep and repeat
|
||||||
|
4. If `succeeded`, job is done (exitCode = 0)
|
||||||
|
5. If `failed`, check `error` and `logs.stderr` for details
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Recommended FFmpeg Command
|
## Recommended FFmpeg Command
|
||||||
@@ -275,16 +257,18 @@ This is correct behavior, not a bug. Use `-progress pipe:1` to get progress in s
|
|||||||
|
|
||||||
## Monitoring FFmpeg Jobs
|
## Monitoring FFmpeg Jobs
|
||||||
|
|
||||||
To watch FFmpeg progress in real-time:
|
To check FFmpeg progress:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Watch the stdout log (with -progress pipe:1)
|
# Get current progress (human-readable)
|
||||||
tail -f /tmp/barn/jobs/<job-id>/logs/stdout.log
|
barn describe <job-id> --logs
|
||||||
|
|
||||||
# Or use barn describe with --logs
|
# Get current progress (JSON for parsing)
|
||||||
watch -n 2 'barn describe <job-id> --logs --output=json | jq -r .logs.stdout'
|
barn describe <job-id> --logs --output=json
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The `logs.stdout` field contains the `-progress pipe:1` output with fields like `frame=`, `fps=`, `speed=`, and `progress=`.
|
||||||
|
|
||||||
## FFmpeg Exit Codes
|
## FFmpeg Exit Codes
|
||||||
|
|
||||||
| Exit Code | Meaning |
|
| Exit Code | Meaning |
|
||||||
|
|||||||
Reference in new issue
Block a user