https://github.com/arenadata/ad-runtime-utils
https://github.com/arenadata/ad-runtime-utils
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/arenadata/ad-runtime-utils
- Owner: arenadata
- Created: 2025-07-22T16:32:01.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2026-01-14T09:57:21.000Z (6 months ago)
- Last Synced: 2026-01-14T13:46:59.492Z (6 months ago)
- Language: Go
- Size: 86.9 KB
- Stars: 0
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
## Why Is This Necessary?
1. **Single Entry Point**
Provides a unified interface for all utility functions (database checks, maintenance tasks, etc.).
2. **One Binary**
Replaces a bunch of shell scripts with a single executable, centralizing logic in one place.
3. **Declarative Configuration**
Uses a YAML‑based config to declare versions, paths, and overrides, making behavior transparent and easy to manage.
4. **Service‑Ready & UI‑Friendly**
Can run as a long‑running service and expose a consistent API for integration with web dashboards or other user interfaces.
## Runtime Detection Algorithm
This section describes how ad-runtime-utils chooses the correct installation path for a given runtime (Java, Python, etc.), both when a service is specified and in the default (no-service) case.
---
### 1. Service-Specific Flow (`--service `)
1. **Service override_path**
- If `services..runtimes..override_path` is set and `/bin/` exists → **return** that path.
2. **Service env_var**
- If `services..runtimes..env_var` is set, and the named environment variable is non-empty and points at a valid `/bin/` → **return** its value.
3. **Service version**
- Read `services..runtimes..version`.
- If missing or empty → **error**:
```
version not specified for service '' runtime ''
```
4. **Per-version Autodetect** (`autodetect.runtimes..`)
1. If `override_path` is set and valid → **return** it.
2. If `env_var` is set and points at a valid path → **return** it.
3. Otherwise, for each glob in `paths` (in order):
- `candidates := Glob(pattern + "*")`
- sort in reverse lexical order
- first candidate with `/bin/` → **return** that path.
5. **Fallback to Default-Flow**
- If none of the above steps succeed, repeat the **Default-Flow** (see below), but format output as:
```
: /path/from/default-flow
```
6. **Error**
- If still nothing is found →
```
no environment found for service '' (version '')
```
---
### 2. Default Flow (no `--service`)
1. **Default override_path**
- If `default.runtimes..override_path` is set and valid → **return** it.
2. **Default env_var**
- If `default.runtimes..env_var` is set and points at a valid path → **return** it.
3. **Default version**
- Read `default.runtimes..version`.
- If missing or empty → **error**:
```
default version not specified for runtime ''
```
4. **Per-version Autodetect** (`autodetect.runtimes..`)
- Same 4.1–4.3 as in the Service-Specific Flow.
5. **Error**
### 3. Listing All Detected Runtimes (--list / -l)
When the --list (or -l) flag is provided:
It outputs all detected runtimes for:
- The default configuration
- Each defined service
```
Default runtimes:
: ">
Service :
: ">
…
```
### 4. Starting a Service
When --start and/or --supervise flags are provided --service is a required argument.
- It starts the executable `services..executable` with the specified arguments from `services..executable_args`.
- If the `--supervise` flag is provided, it will run the health checks, defined in `services..health_checks` on service start to make sure the service is operational. If any of the checks fail the service will be stopped. `Type=notify` should be used in the systemd unit(see example in `examples/systemd` directory).
- While using `--supervise` and health checks, make sure that systemd service has enough `TimeoutStartSec`. ideally should be a combined timeout of all health checks.