mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-11 03:31:55 +00:00
fix(cron): clean up job output dir in remove_job
remove_job() deletes the job from cron/jobs.json but leaves the per-job
output directory at ~/.hermes/cron/output/{job_id}/ behind. Over time
this accumulates orphaned dirs that never get reclaimed.
Adopted from #13510 by @hekaru-agent; the honcho RLock half of that PR
was already salvaged in commit dad021745 so this lands the remaining
cron cleanup hunk on its own.
This commit is contained in:
parent
a3131862bd
commit
f4e621f7d8
1 changed files with 5 additions and 0 deletions
|
|
@ -8,6 +8,7 @@ Output is saved to ~/.hermes/cron/output/{job_id}/{timestamp}.md
|
||||||
import copy
|
import copy
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
import threading
|
import threading
|
||||||
import os
|
import os
|
||||||
|
|
@ -696,6 +697,10 @@ def remove_job(job_id: str) -> bool:
|
||||||
jobs = [j for j in jobs if j["id"] != job_id]
|
jobs = [j for j in jobs if j["id"] != job_id]
|
||||||
if len(jobs) < original_len:
|
if len(jobs) < original_len:
|
||||||
save_jobs(jobs)
|
save_jobs(jobs)
|
||||||
|
# Clean up output directory to prevent orphaned dirs accumulating
|
||||||
|
job_output_dir = OUTPUT_DIR / job_id
|
||||||
|
if job_output_dir.exists():
|
||||||
|
shutil.rmtree(job_output_dir)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue