A Railway cron service that calls configured URLs on a schedule with OpenTelemetry observability.
npm install
npm run buildCopy .env.example and set your values:
cp .env.example .env| Variable | Required | Description |
|---|---|---|
URLS |
Yes | Comma-separated URLs, optionally prefixed with HTTP method |
OTEL_EXPORTER_OTLP_ENDPOINT |
No | OTLP collector endpoint. OTel disabled if not set |
OTEL_SERVICE_NAME |
No | service.name reported to OTel. Falls back to RAILWAY_SERVICE_NAME, then webamigos-rest-caller. Set this to tell multiple deployments apart in telemetry |
TARGET_ENV |
No | local / staging / production. Controls log level (default: local → debug) |
URLS=https://example.com/health,POST:https://example.com/trigger,PUT:https://example.com/refresh
- Default method is
GETwhen no prefix is specified - Supported methods:
GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS
Requests are sent with no custom headers — the caller only knows the method and URL. If a target endpoint is protected, put the credential in the URL as a query param, e.g.:
URLS=POST:https://app.example.com/api/cron/job?secret=<URL_SAFE_SECRET>
Use a URL-safe secret (e.g. openssl rand -hex 32); base64 values can contain
+ / / which get mangled in a URL. The target must accept the secret via the
query string (not only an Authorization header).
npm startThe process calls all configured URLs in parallel, logs results, and exits with code 0 (all succeeded) or 1 (any failed).
When OTEL_EXPORTER_OTLP_ENDPOINT is set, the service exports:
- Traces — automatic HTTP call instrumentation via
@opentelemetry/instrumentation-http - Metrics — exported every 30s
- Logs — pino logs forwarded to OTel Logs API
All telemetry is flushed before the process exits.
Designed to run as a Railway cron job. Railway provides RAILWAY_GIT_COMMIT_SHA automatically, which is used as service.version in OTel resource attributes.