Skip to content

Your lightweight open-source personal agent.

Merge branch 'main' into pr-1339

Re-bin3c6c49cc5d09
diff --cc nanobot/cron/service.py
index cc3b7b2a9,7c7b3e5c2..c3864aeb9
--- a/nanobot/cron/service.py
+++ b/nanobot/cron/service.py
@@@ -69,16 -68,22 +69,22 @@@ class CronService
on_job: Callable[[CronJob], Coroutine[Any, Any, str | None]] | None = None
):
self.store_path = store_path
- self.on_job = on_job # Callback to execute job, returns response text
+ self.on_job = on_job
self._store: CronStore | None = None
+ self._last_mtime: float = 0.0
self._timer_task: asyncio.Task | None = None
self._running = False
-
+
def _load_store(self) -> CronStore:
- """Load jobs from disk."""
+ """Load jobs from disk. Reloads automatically if file was modified externally."""
+ if self._store and self.store_path.exists():
+ mtime = self.store_path.stat().st_mtime
+ if mtime != self._last_mtime:
+ logger.info("Cron: jobs.json modified externally, reloading")
+ self._store = None
if self._store:
return self._store
-
+
if self.store_path.exists():
try:
data = json.loads(self.store_path.read_text(encoding="utf-8"))
@@@ -162,9 -167,10 +168,10 @@@
for j in self._store.jobs
]
}
-
+
self.store_path.write_text(json.dumps(data, indent=2, ensure_ascii=False), encoding="utf-8")
-
+ self._last_mtime = self.store_path.stat().st_mtime
+
async def start(self) -> None:
"""Start the cron service."""
self._running = True