antcolony
All repositories: gitoria
1.6 KB
#!/bin/bash# colony — run the scheduler: ./colony next [--post] | brief <project> <n> [...] | report <file> [--post] | work <project> <n> [...] | check <run dir> [--post] | cycle [--post] [--dry-run] | run [...] | leases [--expire] | ready | deployed <project> <n># The `--` matters: the hybriel binary parses every `--x` after the script itself and refuses it# ("unexpected argument '--post'") unless it follows `--` (found in mission 015).here="$(cd "$(dirname "$0")" && pwd)"# COLONY_HOME: absolute path of this folder — `work` hands absolute paths to the worker's shellexport COLONY_HOME="$here"if [ "$1" != run ] && [ "$1" != agent ]; thenexec "$here/bin/hybriel" "$here/scheduler.hl" -- "$@"fi# `run` (mission 020): Hybriel has no signal handlers, so THIS script catches SIGTERM/SIGINT and tells the# scheduler through a stop file: 1st signal "finish" (start nothing more, let running sessions finish),# 2nd "park" (stop the running sessions and park them). The scheduler runs in its own session (setsid) so a# terminal's Ctrl-C reaches only this script — never the scheduler or its Claude sessions directly.stop="${COLONY_STOP_FILE:-$(mktemp -u "${TMPDIR:-/tmp}/colony-stop.XXXXXXXX")}"rm -f "$stop"export COLONY_STOP_FILE="$stop"signals=0on_signal() {signals=$((signals + 1))if [ "$signals" -ge 2 ]; then echo park > "$stop"; else echo finish > "$stop"; fiecho "colony run: signal $signals received → $(cat "$stop")"}trap on_signal TERM INTsetsid "$here/bin/hybriel" "$here/scheduler.hl" -- "$@" &pid=$!echo "colony run: wrapper pid $$, scheduler pid $pid, stop file $stop"while kill -0 "$pid" 2>/dev/null; dowait "$pid"donerm -f "$stop"echo "colony run: scheduler pid $pid ended"
Branches
- mainmain branch
Latest commits
- 7f9660eeState of 2026-09-27, before the move to gitoriamre