68 lines
2.4 KiB
Bash
Executable File
68 lines
2.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
CONTROL_DIR="$ROOT_DIR/tests/golden/WBV2"
|
|
SCHEDULER_MAX_ITERATIONS="${WBV2_MAX_ITERATIONS:-0}"
|
|
SCHEDULER_POLL_MS="${WBV2_POLL_MS:-1000}"
|
|
SCHEDULER_PUSH_RETRIES="${WBV2_PUSH_RETRIES:-6}"
|
|
WATCHDOG_INTERVAL="${WBV2_WATCHDOG_INTERVAL:-10}"
|
|
WATCHDOG_RESTART_DELAY="${WBV2_WATCHDOG_RESTART_DELAY:-5}"
|
|
|
|
# Keep repository evidence on disk while placing compiler/transient caches in
|
|
# RAM. Eight compile jobs is the repository's stability limit.
|
|
if test -d /dev/shm && test -w /dev/shm; then
|
|
export WEB_RAM_CACHE_ROOT="${WEB_RAM_CACHE_ROOT:-/dev/shm/blender-wasm-$(id -u)}"
|
|
mkdir -p "$WEB_RAM_CACHE_ROOT/emcache" "$WEB_RAM_CACHE_ROOT/tmp"
|
|
export EM_CACHE="${EM_CACHE:-$WEB_RAM_CACHE_ROOT/emcache}"
|
|
export TMPDIR="${TMPDIR:-$WEB_RAM_CACHE_ROOT/tmp}"
|
|
fi
|
|
export CMAKE_BUILD_PARALLEL_LEVEL="${CMAKE_BUILD_PARALLEL_LEVEL:-8}"
|
|
export NINJAFLAGS="${NINJAFLAGS:--j8}"
|
|
|
|
mkdir -p "$CONTROL_DIR"
|
|
|
|
start_scheduler() {
|
|
local pid_file="$CONTROL_DIR/my-tools-scheduler.pid"
|
|
if test -f "$pid_file"; then
|
|
local scheduler_pid
|
|
scheduler_pid="$(tr -d '[:space:]' < "$pid_file")"
|
|
if test -n "$scheduler_pid" && kill -0 "$scheduler_pid" 2>/dev/null; then
|
|
printf 'scheduler already running: %s\n' "$scheduler_pid"
|
|
return
|
|
fi
|
|
rm -f "$pid_file"
|
|
fi
|
|
nohup setsid python3 "$ROOT_DIR/my-tools/run_blender_web_scheduler.py" \
|
|
--max-iterations "$SCHEDULER_MAX_ITERATIONS" \
|
|
--poll-ms "$SCHEDULER_POLL_MS" \
|
|
--push-retries "$SCHEDULER_PUSH_RETRIES" \
|
|
--commit --push \
|
|
> "$CONTROL_DIR/my-tools-scheduler.stdout.log" 2>&1 < /dev/null &
|
|
printf 'scheduler launch pid: %s\n' "$!"
|
|
}
|
|
|
|
start_watchdog() {
|
|
local pid_file="$CONTROL_DIR/my-tools-watchdog.pid"
|
|
if test -f "$pid_file"; then
|
|
local watchdog_pid
|
|
watchdog_pid="$(tr -d '[:space:]' < "$pid_file")"
|
|
if test -n "$watchdog_pid" && kill -0 "$watchdog_pid" 2>/dev/null; then
|
|
printf 'watchdog already running: %s\n' "$watchdog_pid"
|
|
return
|
|
fi
|
|
rm -f "$pid_file"
|
|
fi
|
|
nohup setsid python3 "$ROOT_DIR/my-tools/watch_blender_web_scheduler.py" \
|
|
--interval "$WATCHDOG_INTERVAL" \
|
|
--restart-delay "$WATCHDOG_RESTART_DELAY" \
|
|
--max-iterations "$SCHEDULER_MAX_ITERATIONS" \
|
|
--push-retries "$SCHEDULER_PUSH_RETRIES" \
|
|
--commit --push \
|
|
> "$CONTROL_DIR/my-tools-watchdog.stdout.log" 2>&1 < /dev/null &
|
|
printf 'watchdog launch pid: %s\n' "$!"
|
|
}
|
|
|
|
start_scheduler
|
|
start_watchdog
|