Skip to main content

Module doctor

Module doctor 

Source
Expand description

doctor — pre-flight environment validation command.

Pattern §48: Every server binary MUST implement a doctor subcommand that validates the environment and reports what’s missing before the user tries to start the server.

§Usage

example doctor           # human-readable coloured output; exit 0/1
example doctor --json    # machine-readable JSON; exit 0/1

§CUSTOMIZE

This is the reference implementation for the soma family. When you clone Soma for a real service, the things you MUST change are:

  1. Replace SOMA_API_URL / SOMA_API_KEY with your service’s env vars.
  2. Replace "soma" binary name with your binary name in check_binary_in_path.
  3. Replace ~/.soma/ data dir with your service’s data dir (see config::default_data_dir).
  4. Add any service-specific checks (e.g. database connectivity, auth token format).
  5. Update the print_doctor_report section headings and hint text to match your service.

Nothing else here needs changing for a basic deployment. Business logic for the checks belongs in the individual check_* functions — never in run_doctor.

Structs§

DoctorCheck
A single pre-flight check result.

Functions§

run_doctor
Run the doctor command.