Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,6 @@ output/
# gocd generated output
gocd/templates/vendor/
gocd/generated-pipelines/

# uv
uv.lock
15 changes: 12 additions & 3 deletions src/launchpad/worker/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@
logger = get_logger(__name__)


DEFAULT_HEALTH_CHECK_FILE_PATH = "/tmp/health"


@dataclass
class WorkerConfig:
rpc_hosts: list[str]
concurrency: int
health_check_file_path: str


def get_worker_config() -> WorkerConfig:
Expand All @@ -34,16 +38,20 @@ def get_worker_config() -> WorkerConfig:
except ValueError:
raise ValueError(f"LAUNCHPAD_WORKER_CONCURRENCY must be a valid integer, got: {concurrency_str}")

return WorkerConfig(rpc_hosts=rpc_hosts, concurrency=concurrency)
health_check_file_path = os.getenv("LAUNCHPAD_WORKER_HEALTH_CHECK_FILE_PATH", DEFAULT_HEALTH_CHECK_FILE_PATH)

return WorkerConfig(rpc_hosts=rpc_hosts, concurrency=concurrency, health_check_file_path=health_check_file_path)


def run_worker() -> None:
initialize_sentry_sdk()
config = get_worker_config()

logger.info(f"Starting TaskWorker (rpc_hosts={config.rpc_hosts}, concurrency={config.concurrency})")
logger.info(
f"Starting TaskWorker (rpc_hosts={config.rpc_hosts}, concurrency={config.concurrency}, "
f"health_check_file_path={config.health_check_file_path})"
)

# TODO: Should we explore setting health_check_file_path for K8s file-based liveness probes (TaskWorker has no HTTP server)
worker = TaskWorker(
app_module="launchpad.worker.app:app",
broker_hosts=config.rpc_hosts,
Expand All @@ -54,6 +62,7 @@ def run_worker() -> None:
rebalance_after=16,
processing_pool_name="launchpad",
process_type="forkserver",
health_check_file_path=config.health_check_file_path,
)

exitcode = worker.start()
Expand Down
Loading