openclaw - 💡(How to fix) Fix feat(gateway): graceful config/cron reload without restart [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#54321Fetched 2026-04-08 01:29:03
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Participants
Timeline (top)
cross-referenced ×1

Fix Action

Fix / Workaround

Alternatives considered

  • Editing the store file while gateway is stopped (current workaround — causes downtime)
  • Adding more --clear-* flags to openclaw cron edit (helps specific cases but does not solve the general problem)
RAW_BUFFERClick to expand / collapse

Problem

When agents need to modify cron jobs or gateway config at runtime, the only option is to stop and restart the gateway. This kills all active sessions, drops channel connections, and makes the agent unresponsive until the gateway comes back up.

Common scenarios that currently require a restart:

  • Editing cron job fields not supported by openclaw cron edit (e.g., clearing a model override)
  • Changing config values (model mappings, channel settings)

Proposal

Add a openclaw gateway reload command (or SIGHUP signal handler) that hot-reloads config and cron without killing sessions.

What gets reloaded

  • cron/jobs.json — schedule changes, agent reassignments, payload updates
  • config.json — model mappings, channel settings, plugin configs

What stays alive

  • Active sessions (no dropped conversations)
  • WebSocket/SSE connections to channels
  • In-flight agent turns

Implementation sketch

  1. Gateway registers a SIGHUP handler and/or exposes openclaw gateway reload CLI command
  2. On signal: re-read config files from disk, diff with in-memory state
  3. Hot-swap cron scheduler (cancel old timers, schedule new ones based on updated jobs)
  4. Re-apply config changes
  5. Log what changed, continue serving

Edge cases

  • Cron jobs currently executing during reload: must not double-schedule or orphan running jobs
  • Some config changes may be unsafe to hot-swap (e.g., session store backend) — these should log a warning and require a full restart
  • Code/version updates still require a full restart (reload is config-only)

Alternatives considered

  • Editing the store file while gateway is stopped (current workaround — causes downtime)
  • Adding more --clear-* flags to openclaw cron edit (helps specific cases but does not solve the general problem)

extent analysis

Fix Plan

To implement the openclaw gateway reload command, follow these steps:

  • Register a SIGHUP handler in the gateway to catch the reload signal
  • Create a openclaw gateway reload CLI command to trigger the reload manually
  • Implement the reload logic:
    • Re-read cron/jobs.json and config.json from disk
    • Diff the new config with the in-memory state
    • Hot-swap the cron scheduler:
      • Cancel old timers
      • Schedule new ones based on updated jobs
    • Re-apply config changes, logging warnings for unsafe changes
  • Handle edge cases:
    • Prevent double-scheduling or orphaning of running cron jobs
    • Log warnings for config changes that require a full restart

Example Code

import signal
import json
import logging

# Register SIGHUP handler
def sighup_handler(signum, frame):
    reload_config()

# Create openclaw gateway reload CLI command
def reload_config():
    # Re-read config files from disk
    with open('cron/jobs.json') as f:
        new_cron_jobs = json.load(f)
    with open('config.json') as f:
        new_config = json.load(f)

    # Diff with in-memory state
    diff_cron_jobs = diff_dicts(new_cron_jobs, cron_jobs)
    diff_config = diff_dicts(new_config, config)

    # Hot-swap cron scheduler
    cancel_old_timers()
    schedule_new_timers(diff_cron_jobs)

    # Re-apply config changes
    apply_config_changes(diff_config)

    # Log changes
    logging.info('Config reloaded')

# Helper functions
def diff_dicts(new, old):
    # Calculate diff between two dicts
    pass

def cancel_old_timers():
    # Cancel old timers
    pass

def schedule_new_timers(diff_cron_jobs):
    # Schedule new timers based on updated jobs
    pass

def apply_config_changes(diff_config):
    # Re-apply config changes, logging warnings for unsafe changes
    pass

# Set up signal handler
signal.signal(signal.SIGHUP, sighup_handler)

Verification

To verify the fix, test the following scenarios:

  • Reload config with updated cron jobs
  • Reload config with updated model mappings
  • Reload config with updated channel settings
  • Verify that active sessions and WebSocket/SSE connections remain alive during reload
  • Verify that in-flight agent turns are not affected by the reload

Extra Tips

  • Make sure to handle errors and exceptions properly during the reload process
  • Consider adding logging and monitoring to track config reloads and any issues that may arise
  • Test the reload functionality thoroughly to ensure it works as expected in different scenarios.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix feat(gateway): graceful config/cron reload without restart [1 participants]