Mirrored from GitHub
github.com/roostorg/osprey
1#!/bin/bash
2
3usage() {
4 cat <<EOF
5Usage: entrypoint.sh <command>
6Osprey docker entrypoint.
7
8Commands:
9 osprey-worker
10 Runs the worker
11 osprey-async-worker
12 [EXPERIMENTAL] Runs the asyncio-native worker (Phase 0; async image only)
13 osprey-ui-api
14 Runs the Osprey UI API
15 run-tests
16 Runs tests for the various projects supported here
17 operator
18 Waits.
19EOF
20 exit 1
21}
22
23cli-osprey-ui-api() {
24 exec uv run gunicorn \
25 --reload \
26 --access-logfile - \
27 --error-logfile - \
28 --name osprey_ui_api \
29 --worker-class gevent \
30 --chdir /osprey/osprey_worker/src \
31 --bind :5004 \
32 "osprey.worker.ui_api.osprey.app:create_app()"
33}
34
35cli-osprey-worker() {
36 exec uv run python3.11 osprey_worker/src/osprey/worker/cli/sinks.py run-rules-sink
37}
38
39cli-osprey-async-worker() {
40 # EXPERIMENTAL: asyncio-native worker (Phase 0 — static/JSONL input, stdout sink;
41 # no Kafka/coordinator input wired upstream yet). Only functional in the
42 # osprey_async_worker/Dockerfile image, which installs osprey_async_worker.
43 # Defaults to the bundled stdlib example rules so the image runs out of the box;
44 # set OSPREY_INPUT_FILE to feed a JSONL action file (otherwise input is empty).
45 local rules_path="${OSPREY_RULES_PATH:-/osprey/osprey_async_worker/example_rules}"
46 local args=(run --rules-path "${rules_path}")
47 if [[ -n "${OSPREY_INPUT_FILE:-}" ]]; then
48 args+=(--input-file "${OSPREY_INPUT_FILE}")
49 fi
50 exec uv run osprey-async-cli "${args[@]}" "$@"
51}
52
53cli-run-tests() {
54 # Only use in CI via harbormaster buildkite run_tests VARIANT PROJECT [directories]
55 # Docker command will be run-tests --junitxml=/osprey/junit-pytest.xml [directory]
56 # Last argument is the directory, the rest are pytest args
57 exec uv run python3.11 -m gevent.monkey --module pytest "${@}"
58}
59
60cli-operator() {
61 while true; do
62 sleep 600
63 done
64}
65
66cmd="${1:-}"
67case "${cmd}" in
68"" | "-h" | "--help")
69 usage
70 ;;
71*)
72 if [[ "$(type -t "cli-${cmd}")" = "function" ]]; then
73 shift
74 "cli-${cmd}" "$@"
75 else
76 echo "Unknown command: ${cmd}"
77 echo ""
78 usage
79 fi
80 ;;
81esac