hero_proc forks managed daemons without propagating PATH_ROOT — daemons panic at startup #109
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_proc#109
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?
Context
Discovered by the hero_skills#261 agent while bootstrapping
hero_service. The agent could launch bothhero_service_serverandhero_service_adminbinaries directly and they worked fine, but whenhero_proc startforked them as managed daemons they panicked at startup becausePATH_ROOTwasn't in their environment.What to do
Pick one (or both):
PATH_ROOT,HERO_SOCKET_DIR, etc.), from the supervisor to the child at fork time.~/hero/cfg/env/and have managed daemons source those at startup (matches the existingforgejo.env/secrets.envpattern).The persist-and-load path is the more durable fix since it survives
hero_procrestart without depending on whoever started the supervisor.Acceptance
hero_proc start <service>works for a service that requiresPATH_ROOTwithout the user explicitly exporting it inhero_proc's shell.Related
Starting work on this. Branch:
issue-109-path-root-env(offdevelopment).Investigation summary:
hero_proc_serverspawns child processes viatokio::process::Commandincrates/hero_proc_server/src/supervisor/executor.rs(run_job_regular/run_job_pty).env_clear()is called, so children DO inherit the supervisor parent env by default. The added vars are only context secrets + the job spec'senvmap.hero_proc_serveritself is launched withoutPATH_ROOT/HERO_SOCKET_DIRetc. in its own environment (e.g. via screen/daemon mode, without a login shell that sources~/hero/cfg/env/*.env). Children then also lack them.Picking option (B) — persist-and-load, matches the existing
forgejo.env/secrets.envpattern and survives supervisor restart:hero_proc_serverstartup, before child processes can spawn, read~/hero/cfg/env/*.envand inject anyexport KEY=VALUElines intostd::env(without overriding values already present — the user's shell still wins).Will push once
cargo checkis clean.Implemented in branch
issue-109-path-root-env(commit72849b8).Root cause:
hero_proc_serverspawns children viatokio::process::Commandwithoutenv_clear(), so children inherit the supervisor env. When the supervisor itself is launched withoutHERO_*vars in its environment (screen, systemd, non-login shell), children panic on missingPATH_ROOT/HERO_SOCKET_DIR.Fix: New
hero_proc_server::env_loadruns at startup, scans~/hero/cfg/env/*.env, parses minimal shell-style env files (supportsexport K=V, comments, quoted values), and callsstd::env::set_varfor each entry — only if the key is not already set, so explicit shell overrides still win. Existing fork path needs no changes; children inherit naturally.HERO_CFG_ENV_DIRoverrides the dir for tests.set_varruns before tokio spawns threads (2024-edition safety contract).Diff: 3 files / +284 lines (
crates/hero_proc_server/src/env_load.rs,lib.rs,main.rs). Branch pushed; ready for review.