mirror of
https://github.com/hyperdxio/hyperdx
synced 2026-04-21 13:37:15 +00:00
## Summary The node commands to start the API server and alert task are duplicated across 4+ files, each hardcoding the build output path and node require flags. When the build process changed (esbuild introduction/revert per HDX-2690), the downstream operator and helm chart broke because their entrypoint commands were stale. This PR introduces `packages/api/bin/hyperdx`, a single shell script that is the **sole source of truth** for how to launch API and task processes. It resolves the build directory relative to its own location, applies the correct node flags (`-r @hyperdx/node-opentelemetry/build/src/tracing`), and exposes two subcommands: - `hyperdx api` -- starts the API server - `hyperdx task <name>` -- runs a named task (e.g., `check-alerts`) All Dockerfiles and entry scripts now delegate to this script instead of inlining the node command. Future build changes only need updating in one place. ### How to test locally or on Vercel 1. **Build the standalone API image** and confirm the entrypoint works: ```bash docker build . -f packages/api/Dockerfile -t hyperdx-api-test:latest --target prod docker run -d --name hdx-api-test -p 18000:8000 hyperdx-api-test:latest sleep 5 docker logs hdx-api-test 2>&1 | head -30 # Should show OpenTelemetry init + MongoStore error (expected without Mongo) # No "file not found" or "permission denied" errors docker stop hdx-api-test && docker rm hdx-api-test ``` 2. **Build and run the all-in-one image** for a full integration test: ```bash make build-local docker run -d --name hdx-aio-test -p 18080:8080 -p 18000:8000 hyperdx/hyperdx-local:2.21.0 # Wait up to 90s for startup, then: curl -sf http://localhost:18080/api/health # should return {"data":"OK",...} curl -sf http://localhost:18000/health # should return {"data":"OK",...} docker exec hdx-aio-test sh -c "ps aux" # Confirm API, APP, and ALERT-TASK processes are running via the hyperdx script docker stop hdx-aio-test && docker rm hdx-aio-test ``` 3. **Build the prod image** to confirm the entry script changes are valid: ```bash make build-app ``` **Testing performed:** All three Docker image targets were built and verified locally. The standalone API image started node via `hyperdx api` correctly (crashed on missing MongoDB as expected). The all-in-one image passed health checks on both `localhost:18080/api/health` and `localhost:18000/health`, with all three processes (API, APP, ALERT-TASK) confirmed running inside the container using the new entry point script. ### References - Linear Issue: [HDX-2712](https://linear.app/clickhouse/issue/HDX-2712/use-a-single-entry-point-script-for-both-hyperdx-api-and-alert-job) - Related PRs: HDX-2690 (root cause), HDX-2815 (downstream helm chart follow-up) - **Follow-up needed:** Update helm chart cron job template and operator template in `ClickHouse/ClickStack-helm-charts` to use `./packages/api/bin/hyperdx task check-alerts` Made with [Cursor](https://cursor.com) |
||
|---|---|---|
| .. | ||
| clickhouse/local | ||
| hostmetrics | ||
| hyperdx | ||
| nginx | ||
| otel-collector | ||