Golang-based Watchdog service for OBA REST API servers
Go 1.23 or higher
The watchdog service can be configured using either:
- A local JSON configuration file (
--config-file
). - A remote JSON configuration URL (
--config-url
).
The JSON configuration file should contain an array of ObaServer
objects. Example:
[
{
"name": "Test Server",
"id": 1,
"oba_base_url": "https://test.example.com",
"oba_api_key": "test-key",
"gtfs_url": "https://gtfs.example.com",
"trip_update_url": "https://trip.example.com",
"vehicle_position_url": "https://vehicle.example.com",
"gtfs_rt_api_key": "api-key",
"gtfs_rt_api_value": "api-value"
}
]
go run ./cmd/watchdog/ --config-file /path/to/your/config.json
To load the configuration from a remote URL that requires basic authentication, follow these steps:
Before running the application, set the CONFIG_AUTH_USER
and CONFIG_AUTH_PASS
environment variables with the username and password for authentication.
export CONFIG_AUTH_USER="your_username"
export CONFIG_AUTH_PASS="your_password"
set CONFIG_AUTH_USER=your_username
set CONFIG_AUTH_PASS=your_password
Use the --config-url flag to specify the remote configuration URL. For example:
go run ./cmd/watchdog/ \
--config-url http://example.com/config.json
You can also run the application using Docker. Here’s how:
First, build the Docker image for the application. Navigate to the root of the project directory and run:
docker build -t watchdog .
docker run -d \
--name watchdog \
-e CONFIG_AUTH_USER=admin \
-e CONFIG_AUTH_PASS=password \
-p 3000:3000 \
watchdog \
--config-url http://example.com/config.json
go test ./...