Skip to content

fix(cron): add standalone cron daemon mode - #41167

Closed
alaamohanad169-ship-it wants to merge 3 commits into
NousResearch:mainfrom
alaamohanad169-ship-it:fix/cron-daemon-standalone
Closed

fix(cron): add standalone cron daemon mode#41167
alaamohanad169-ship-it wants to merge 3 commits into
NousResearch:mainfrom
alaamohanad169-ship-it:fix/cron-daemon-standalone

Conversation

@alaamohanad169-ship-it

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds hermes cron daemon command to run the cron scheduler as a standalone process, independent of the gateway.

Problem: Cron jobs don't execute on systems where the gateway isn't running (Windows without service installation, headless servers, etc.). The cron scheduler only runs inside the gateway process, so if the gateway isn't started, cron jobs never fire.

Solution: New hermes cron daemon command that runs the same tick loop as the gateway's internal cron ticker, but as a standalone process.

Changes Made

  • hermes_cli/cron.py: Added cron_daemon() function that runs the cron tick loop with signal handling
  • hermes_cli/main.py: Added daemon subcommand parser with --interval option (default 60s)

How to Test

  1. Create a cron job:

    hermes cron create "* * * * *" "Test job - just print hello" --name test-daemon
    
  2. Start the cron daemon:

    hermes cron daemon --interval 60
    
  3. Verify the job executes (check hermes cron list for last_run_at)

  4. Stop with Ctrl+C

Related Issue

Fixes #41037 (Cron jobs never execute: last_run_at always null after manual trigger)

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (standalone cron daemon mode)

Checklist

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix
  • I've tested on my platform: Android/Termux

…g provider

When running `hermes model` to add/configure a provider without intending to
switch the default, the wizard previously overwrote model.base_url and
model.provider, breaking the previously-working default model.

This fix adds a confirmation prompt: 'Make <provider> your default provider?'
If the user answers 'no', the provider is configured (credentials, base_url)
without changing the active default model.

Fixes #40862
Add `hermes cron daemon` command to run the cron scheduler independently
of the gateway. This fixes the issue where cron jobs don't execute on
systems where the gateway isn't running (e.g., Windows without service
installation, or when running headless).

The daemon runs the same tick loop as the gateway's internal cron ticker,
but as a standalone process that can be started with:
  hermes cron daemon [--interval 60]

This allows cron jobs to execute on any platform without requiring the
gateway to be running.
@liuhao1024

Copy link
Copy Markdown
Contributor

Scope concern — two unrelated features in one PR

The diff contains two separate features that should be separate PRs:

  1. Cron daemon mode (hermes_cli/cron.py): Adds cron_daemon() with signal handling, event-based stop, and hermes cron daemon subcommand. Clean and focused.

  2. Provider configure-without-switching (hermes_cli/main.py): Adds a 179-line _configure_provider_only() function and a "Make this your default provider? [Y/n]" prompt to hermes model. This is a UX change to the model selection flow, unrelated to cron.

Bundling unrelated changes makes review harder and increases the chance of one feature blocking the other. Consider splitting the provider config changes into a separate PR.

Also a minor note: import signal at the module level (line 5) is shadowed by import signal inside cron_daemon() (line 337). The inner import is redundant.

@alt-glitch alt-glitch added type/feature New feature or request comp/cron Cron scheduler and job management comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists labels Jun 7, 2026
@alaamohanad169-ship-it

Copy link
Copy Markdown
Contributor Author

Closing in favor of clean PR #41363 which only contains the cron daemon changes without the unrelated model wizard changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/cron Cron scheduler and job management P2 Medium — degraded but workaround exists type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cron jobs never execute: last_run_at always null after manual trigger

3 participants