diff --git a/my-tools/start_unattended.sh b/my-tools/start_unattended.sh index 8e4960d98..8a08d08df 100755 --- a/my-tools/start_unattended.sh +++ b/my-tools/start_unattended.sh @@ -9,6 +9,7 @@ SCHEDULER_PUSH_RETRIES="${WBV2_PUSH_RETRIES:-6}" WATCHDOG_INTERVAL="${WBV2_WATCHDOG_INTERVAL:-10}" WATCHDOG_RESTART_DELAY="${WBV2_WATCHDOG_RESTART_DELAY:-5}" AUTO_AUTHORIZE="${WBV2_AUTO_AUTHORIZE:-1}" +WAIT_ON_EMPTY="${WBV2_WAIT_ON_EMPTY:-1}" # Keep repository evidence on disk while placing compiler/transient caches in # RAM. Eight compile jobs is the repository's stability limit. @@ -46,9 +47,13 @@ start_scheduler() { start_watchdog() { local pid_file="$CONTROL_DIR/my-tools-watchdog.pid" local auto_authorize_args=() + local wait_on_empty_args=() if test "$AUTO_AUTHORIZE" != "0"; then auto_authorize_args+=(--auto-authorize) fi + if test "$WAIT_ON_EMPTY" != "0"; then + wait_on_empty_args+=(--wait-on-empty) + fi if test -f "$pid_file"; then local watchdog_pid watchdog_pid="$(tr -d '[:space:]' < "$pid_file")" @@ -64,6 +69,7 @@ start_watchdog() { --max-iterations "$SCHEDULER_MAX_ITERATIONS" \ --push-retries "$SCHEDULER_PUSH_RETRIES" \ "${auto_authorize_args[@]}" \ + "${wait_on_empty_args[@]}" \ --commit --push \ > "$CONTROL_DIR/my-tools-watchdog.stdout.log" 2>&1 < /dev/null & printf 'watchdog launch pid: %s\n' "$!" diff --git a/my-tools/watch_blender_web_scheduler.py b/my-tools/watch_blender_web_scheduler.py index 1cc403384..98c0f7fc2 100755 --- a/my-tools/watch_blender_web_scheduler.py +++ b/my-tools/watch_blender_web_scheduler.py @@ -112,6 +112,8 @@ def main() -> int: parser.add_argument("--push-retries", type=int, default=6) parser.add_argument("--auto-authorize", dest="auto_authorize", action="store_true", default=os.getenv("WBV2_AUTO_AUTHORIZE", "1") != "0", help="authorize a source-backed successor when the queue reaches a terminal task") parser.add_argument("--no-auto-authorize", dest="auto_authorize", action="store_false") + parser.add_argument("--wait-on-empty", dest="wait_on_empty", action="store_true", default=os.getenv("WBV2_WAIT_ON_EMPTY", "0") != "0", help="keep the watchdog alive when no source-backed batch is currently configured") + parser.add_argument("--no-wait-on-empty", dest="wait_on_empty", action="store_false") args = parser.parse_args() if args.interval <= 0 or args.restart_delay < 0 or args.max_restarts < 0 or args.max_iterations < 0: parser.error("interval/delay/limits must be non-negative; interval must be positive") @@ -174,6 +176,22 @@ def main() -> int: "authorizationLog": str(AUTHORIZATION_LOG.relative_to(ROOT)), }, ) + if reason == "no_configured_unresolved_source_batch" and args.wait_on_empty: + write_json( + WATCHDOG_STATUS, + { + "schemaVersion": 1, + "status": "waiting_for_source_batch", + "reason": reason, + "task": pointer.get("task"), + "updatedAt": now(), + "restartCount": restarts, + "authorizationLog": str(AUTHORIZATION_LOG.relative_to(ROOT)), + }, + ) + child = None + time.sleep(max(args.interval, 60.0)) + continue return 0 if reason == "no_configured_unresolved_source_batch" else 2 if terminal_pointer(pointer) or (applies and state in {"complete", "blocked", "stopped"}): write_json(