openclaw - 💡(How to fix) Fix boot-md hook re-runs BOOT.md on every gateway restart [1 comments, 2 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#52767Fetched 2026-04-08 01:19:43
View on GitHub
Comments
1
Participants
2
Timeline
1
Reactions
0
Timeline (top)
commented ×1
RAW_BUFFERClick to expand / collapse

Bug Description

boot-md is a gateway internal hook that runs BOOT.md every time the gateway starts. However, BOOT.md is designed for first-run initialization — it should only run once, not on every startup.

Actual Behavior

Every gateway restart unconditionally executes BOOT.md, causing unnecessary re-execution of one-time initialization logic.

Impact

  • Unnecessary boot overhead on every restart
  • Risk of session corruption if boot-md races with active sessions
  • heartbeat cron → boot-md → session stuck in loop → gateway freeze (607KB file)

Environment

  • OpenClaw 2026.3.13 (61d171a)
  • Platform: Ubuntu 24.04 / WSL2

Suggested Fix

  1. Make boot-md idempotent (track run state in a flag file)
  2. Check inside BOOT.md whether initialization has already been done
  3. Redesign boot-md to not be a startup hook

extent analysis

Fix Plan

To address the issue, we will make boot-md idempotent by tracking its run state in a flag file. Here are the steps:

  • Create a flag file, e.g., /var/lib/boot-md/initialized
  • Modify BOOT.md to check for the existence of the flag file before running initialization logic
  • If the flag file exists, skip initialization; otherwise, create the flag file after initialization

Example Code

# In BOOT.md
if [ -f "/var/lib/boot-md/initialized" ]; then
  echo "Already initialized, skipping..."
  exit 0
fi

# One-time initialization logic here

# Create flag file after initialization
touch /var/lib/boot-md/initialized

Alternatively, you can use a more robust approach using a lockfile:

# In BOOT.md
lockfile="/var/lib/boot-md/initialized"
if [ -f "$lockfile" ]; then
  echo "Already initialized, skipping..."
  exit 0
fi

# One-time initialization logic here

# Create lockfile after initialization
flock -x "$lockfile" true

Verification

To verify the fix, restart the gateway and check that BOOT.md only runs once. You can add logging statements to BOOT.md to confirm that the initialization logic is skipped on subsequent restarts.

Extra Tips

  • Consider using a more robust storage mechanism, such as a database or a dedicated configuration file, to track the initialization state.
  • If you choose to redesign boot-md to not be a startup hook, ensure that the initialization logic is still executed at the appropriate time, e.g., during the first run of the gateway.

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 boot-md hook re-runs BOOT.md on every gateway restart [1 comments, 2 participants]