check code & example #1
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_website_framework#1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
make 'make' file in example
examples/simple_website
so its easy to start example website
make sure the example website uses /hero_proc_log_selfstart_check
explain difference between
maybe one no longer needed
put als make file in crates/demo_website
the /Volumes/T7/code0/hero_website_framework/crates/hero_website_lib/src needs to make it easy for example website to use
/hero_proc_log_selfstart_check
make sure its re-usable code
Implementation Spec — Issue #1: Check Code & Example
Background: demo_website vs simple_website
crates/demo_websiteexamples/simple_websitemake demorunsBoth are kept. Neither should be deleted.
Objective
Makefiletoexamples/simple_website/andcrates/demo_website/hero_proclifecycle module tohero_website_lib(selfstart/selfstop/HeroLogger)examples/simple_websiteto use--start/--stop/--portvia the new library helpers--start/--stoptocrates/demo_websiteas wellRequirements
examples/simple_website/Makefilewith targets:help,build,dev,run,start,stop,check,fmt,cleancrates/demo_website/Makefilewith same targetshero_website_lib: addhero_procfeature flag with optionalhero_proc_sdkdependencyhero_website_lib/src/hero_proc_lifecycle.rs: reusableSelfStartConfig,self_start(),self_stop(),HeroLoggerre-exportexamples/simple_website/src/main.rs: addCliwith--start/--stop/--port, dispatch accordingly, add HeroLoggercrates/demo_website/src/main.rs: add--start/--stopto existing CLIImplementation Steps
Step 1 — Add
hero_proc_sdkto workspaceCargo.tomlFiles:
Cargo.tomlAdd
hero_proc_sdkas workspace dependency (path or git). Also addanyhow,dirs.Dependencies: none
Step 2 — Add
hero_procfeature tohero_website_lib/Cargo.tomlFiles:
crates/hero_website_lib/Cargo.tomlAdd optional
hero_proc_sdk,anyhow,dirsbehindhero_procfeature flag.Dependencies: Step 1
Step 3 — Create
hero_proc_lifecycle.rsinhero_website_libFiles:
crates/hero_website_lib/src/hero_proc_lifecycle.rs,crates/hero_website_lib/src/lib.rsImplement
SelfStartConfig,self_start(),self_stop(), re-exportHeroLogger.Follow pattern from
hero_books_server/src/main.rs.Dependencies: Step 2
Step 4 — Update
examples/simple_website/Cargo.tomlFiles:
examples/simple_website/Cargo.tomlAdd
clap,anyhow; enablehero_procfeature onhero_website_lib.Dependencies: Step 2
Step 5 — Rewrite
examples/simple_website/src/main.rsFiles:
examples/simple_website/src/main.rsAdd
Clistruct with--start/--stop/--port, dispatch toself_start/self_stop, addHeroLogger.Dependencies: Steps 3, 4
Step 6 — Create
examples/simple_website/MakefileFiles:
examples/simple_website/MakefileTargets:
help,build,dev(runs directly with--port),start,stop,check,fmt,clean.Dependencies: Step 5
Step 7 — Create
crates/demo_website/MakefileFiles:
crates/demo_website/MakefileSame targets, delegates to root
cargo. Port defaults to 4328.Dependencies: none (can run parallel with Step 6)
Step 8 — Add
--start/--stoptocrates/demo_website/src/main.rsFiles:
crates/demo_website/src/main.rs,crates/demo_website/Cargo.tomlAdd
--start/--stopto existingCli, enablehero_procfeature onhero_website_lib.Dependencies: Step 3
Step 9 — Update documentation
Files:
README.md(or newDIFFERENCES.md),QUICKSTART.mdAdd demo_website vs simple_website comparison table.
Add selfstart code snippet in QUICKSTART.md.
Dependencies: none (can run parallel)
Acceptance Criteria
cd examples/simple_website && make devstarts on TCP port, no hero_proc neededcd examples/simple_website && make buildcompiles cleanlycd crates/demo_website && make devstarts demo_website on port 4328hero_website_libcompiles withouthero_procfeaturehero_website_libcompiles withhero_procfeaturesimple_website --startregisters with hero_proccargo check --workspace --all-targetspassesNotes
hero_proc_sdkpath:/Volumes/T7/code0/hero_proc/crates/hero_proc_sdk(co-located checkout)HeroLoggeris non-fatal — silent if hero_proc unreachable (safe formake dev)demo_websitesocket name iswebsite_demo(from existing code)simple_websiteport: 4329 (avoids conflict with demo_website at 4328)Build Check Results
Without hero_proc feature
With hero_proc feature
Root cause: Both builds fail because the path dependency
/Volumes/T7/hero_proc/crates/hero_proc_sdk/Cargo.tomldoes not exist on this machine. Thehero_proc_sdkcrate is referenced as a local path dependency but thehero_procrepository is not present at the expected location.Implementation Summary
Changes Made
Cargo.toml(workspace)anyhow = "1"to workspace dependencieshero_proc_sdk = { path = "../hero_proc/crates/hero_proc_sdk" }to workspace dependenciesexamples/simple_websitefrom workspace memberscrates/hero_website_lib/Cargo.tomlhero_proc_sdkandanyhowdependencieshero_procfeature flag:hero_proc = ["dep:hero_proc_sdk", "dep:anyhow"]hero_proctofullfeaturecrates/hero_website_lib/src/hero_proc_lifecycle.rs(new)SelfStartConfigstructpub async fn self_start(config: &SelfStartConfig) -> anyhow::Result<()>pub async fn self_stop(service_name: &str) -> anyhow::Result<()>HeroLoggerfromhero_proc_sdkcrates/hero_website_lib/src/lib.rshero_proc_lifecyclemodule and re-exported key types under#[cfg(feature = "hero_proc")]crates/demo_website/Cargo.tomlhero_procfeature onhero_website_libanyhowworkspace dependencycrates/demo_website/src/main.rs--startand--stopCLI flags toClistructself_start/self_stopat startupHeroLogger::new("website_demo")initializationmain()return type toanyhow::Result<()>crates/demo_website/Makefile(new)help,build,dev(port 4328),start,stop,check,fmt,cleanREADME.md## Examplessection explainingcrates/demo_websiteas the reference implementationQUICKSTART.md(new)--start/--stopexplanation and code snippetexamples/simple_website/— removed (not needed)Build Results
cargo check --workspace— ✅ passes (2 pre-existing dead_code warnings in demo_website)cargo check -p hero_website_lib --features hero_proc— ✅ passeshero_website_lib#4