Class: ReactOnRails::Dev::ServiceChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/react_on_rails/dev/service_checker.rb

Overview

ServiceChecker validates that required external services are running before starting the development server.

Configuration is read from .dev-services.yml in the app root:

services:

redis:
  check_command: "redis-cli ping"
  expected_output: "PONG"
  start_command: "redis-server"
  description: "Redis (for caching and background jobs)"
postgresql:
  check_command: "pg_isready"
  expected_output: "accepting connections"
  start_command: "pg_ctl -D /usr/local/var/postgres start"
  description: "PostgreSQL database"

Constant Summary collapse

CONFIG_KEYS =

Configuration file keys

{
  services: "services",
  check_command: "check_command",
  expected_output: "expected_output",
  start_command: "start_command",
  install_hint: "install_hint",
  description: "description"
}.freeze

Class Method Summary collapse

Class Method Details

.check_services(config_path: ".dev-services.yml") ⇒ Boolean

Check all required services and provide helpful output

Parameters:

  • config_path (String) (defaults to: ".dev-services.yml")

    Path to .dev-services.yml (default: ./.dev-services.yml)

Returns:

  • (Boolean)

    true if all services are running or no config exists



42
43
44
45
46
47
48
49
# File 'lib/react_on_rails/dev/service_checker.rb', line 42

def check_services(config_path: ".dev-services.yml")
  return true unless File.exist?(config_path)

  config = load_config(config_path)
  return true unless config_has_services?(config)

  check_and_report_services(config, config_path)
end