Add hero_proc_sdk::lifecycle module — shared start/stop helpers for all services #66

Closed
opened 2026-03-20 14:17:24 +00:00 by mik-tf · 1 comment
Owner

Problem

Every Hero service that self-registers with hero_proc duplicates ~80 lines of boilerplate:

  • self_start(): connect to hero_proc, register actions, register service, start service, wait for healthy
  • self_stop(): connect to hero_proc, check status, stop service, wait for halted
  • wait_for_healthy(): poll service status until "ok" or timeout
  • wait_for_halted(): poll service status until "halted" or timeout

This is copy-pasted across hero_embedder, hero_os, hero_inspector, hero_books, hero_voice, hero_redis, hero_aibroker, and others.

Commit 56856ef in hero_inspector attempted to use hero_proc_sdk::lifecycle::start_service() / stop_service() — but the module was never created, breaking the build. Fixed in #65 by inlining the pattern, but the shared module should exist.

Solution

Add hero_proc_sdk::lifecycle module providing:

pub async fn start_service(
    client: &HeroProcRPCAPIClient,
    name: &str,
    service: Service,
    timeout_secs: u64,
) -> Result<()>

pub async fn stop_service(
    client: &HeroProcRPCAPIClient,
    name: &str,
    timeout_secs: u64,
) -> Result<()>

Then migrate all services to use it.

Repos

  • hero_proc (add lifecycle module to hero_proc_sdk)
  • hero_embedder, hero_os, hero_inspector, hero_books, hero_voice, hero_redis, hero_aibroker, hero_indexer, hero_foundry (migrate to shared helpers)

Ref: #50 (original plan), #65 (where the inline fix was applied)

Signed-off-by: mik-tf

## Problem Every Hero service that self-registers with hero_proc duplicates ~80 lines of boilerplate: - `self_start()`: connect to hero_proc, register actions, register service, start service, wait for healthy - `self_stop()`: connect to hero_proc, check status, stop service, wait for halted - `wait_for_healthy()`: poll service status until "ok" or timeout - `wait_for_halted()`: poll service status until "halted" or timeout This is copy-pasted across hero_embedder, hero_os, hero_inspector, hero_books, hero_voice, hero_redis, hero_aibroker, and others. Commit `56856ef` in hero_inspector attempted to use `hero_proc_sdk::lifecycle::start_service()` / `stop_service()` — but the module was never created, breaking the build. Fixed in #65 by inlining the pattern, but the shared module should exist. ## Solution Add `hero_proc_sdk::lifecycle` module providing: ```rust pub async fn start_service( client: &HeroProcRPCAPIClient, name: &str, service: Service, timeout_secs: u64, ) -> Result<()> pub async fn stop_service( client: &HeroProcRPCAPIClient, name: &str, timeout_secs: u64, ) -> Result<()> ``` Then migrate all services to use it. ## Repos - hero_proc (add lifecycle module to hero_proc_sdk) - hero_embedder, hero_os, hero_inspector, hero_books, hero_voice, hero_redis, hero_aibroker, hero_indexer, hero_foundry (migrate to shared helpers) Ref: #50 (original plan), #65 (where the inline fix was applied) Signed-off-by: mik-tf
Author
Owner

All 7 services now use hero_proc_sdk::lifecycle::{start_service, stop_service} for their --start/--stop paths:

  • hero_aibroker_server — replaced ~130 lines of manual boilerplate
  • hero_aibroker_ui — replaced ~130 lines (preserves .requires(["hero_aibroker_server"]))
  • hero_embedder_server — replaced ~120 lines (preserves OpenRPC socket health check)
  • hero_embedder_ui — replaced ~120 lines (preserves health check with start_period=3000)
  • hero_embedder_proxy — replaced ~120 lines (preserves runtime args in exec_cmd + health check)
  • hero_inspector_server — replaced ~110 lines (preserves OpenRPC socket health check)
  • hero_inspector_ui — replaced ~165 lines (preserves health check + .requires(["hero_inspector_server"]))

~895 lines of duplicated registration/polling boilerplate → ~70 lines total. One clean pattern across all services as per issue #50.

Build: 18/18 succeeded, 0 failed, 41 binaries.

Repos touched: hero_aibroker, hero_embedder, hero_inspector (all pushed to development).

All 7 services now use `hero_proc_sdk::lifecycle::{start_service, stop_service}` for their `--start`/`--stop` paths: - **hero_aibroker_server** — replaced ~130 lines of manual boilerplate - **hero_aibroker_ui** — replaced ~130 lines (preserves `.requires(["hero_aibroker_server"])`) - **hero_embedder_server** — replaced ~120 lines (preserves OpenRPC socket health check) - **hero_embedder_ui** — replaced ~120 lines (preserves health check with start_period=3000) - **hero_embedder_proxy** — replaced ~120 lines (preserves runtime args in exec_cmd + health check) - **hero_inspector_server** — replaced ~110 lines (preserves OpenRPC socket health check) - **hero_inspector_ui** — replaced ~165 lines (preserves health check + `.requires(["hero_inspector_server"])`) ~895 lines of duplicated registration/polling boilerplate → ~70 lines total. One clean pattern across all services as per issue #50. Build: 18/18 succeeded, 0 failed, 41 binaries. Repos touched: hero_aibroker, hero_embedder, hero_inspector (all pushed to development).
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/home#66
No description provided.