Predefined health check for Redis cache server.
This module provides a ready-to-use check that verifies Redis
is accessible. It prefers the redis-cli binary and falls back
to a raw TCP port check (via Trebejo.Network.port_open?/3) when
the binary is not installed.
All command execution uses arg lists — never interpolated into
shell strings — to prevent shell injection. Routed through
Trebejo.Util.run_cmd_legacy/3 for consistent timeout handling
and structured errors.
Usage
config = %{
app_name: "myapp",
checks: [
Botica.Batteries.Redis.check()
]
}Options
:host- Redis host (default: "localhost"):port- Redis port (default: 6379):timeout- Check timeout in ms (default: 5000)
Summary
Functions
@spec check_connection(String.t(), non_neg_integer()) :: Botica.Types.check_result()
Checks if Redis is responding to PING.
Uses redis-cli when available. Falls back to a TCP probe on
the configured port via Trebejo.Network.port_open?/3 when the
binary is not installed.
@spec start_service() :: Botica.Types.fix_result()
Attempts to start the Redis service.
Tries systemctl start redis-server first, falls back to
systemctl start redis for distros that name the unit differently.