Add self-update command and background update check#106
Merged
Conversation
Implements `clickhousectl update` to download the latest release from GitHub and replace the running binary in-place. Also adds a background version check that runs on every command (cached for 24h) and prints a notice to stderr when a newer version is available. Closes #103 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Two fixes: - Split the background update check into a sync cache-read phase (prints notice before the command runs, no interleaved output) and a fire-and-forget async refresh (never awaited, never prints). The next invocation sees the refreshed cache. - Add a 10s timeout to the GitHub API client so even explicit `update`/`update --check` commands don't hang on unreachable hosts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…d client - Await the cache refresh handle with a 5s timeout so short-lived commands (local which, --version, etc.) don't drop the task before the cache write completes, while still bounding the worst case. - Add 5-minute timeout to the download client in perform_update so `clickhousectl update` can't hang indefinitely on a stalled connection. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The implicit background check should never degrade CLI responsiveness. - Background GitHub API request now has a 400ms timeout (vs 10s for explicit `update`/`update --check` commands). - On any failure (timeout, network error, etc.), write the current version to the cache so we back off for 24 hours instead of retrying on every invocation. - Grace period at exit reduced from 5s to 500ms (just enough headroom above the 400ms HTTP timeout for the cache file write). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
iskakaushik
approved these changes
Apr 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
clickhousectl updatecommand that downloads the latest release binary from GitHub Releases and replaces the current binary in-placeclickhousectl update --checkto check for updates without installing~/.clickhouse/last_update_check) and prints a notice to stderr when a newer version is availableTest plan
cargo buildpassescargo testpasses (254 tests, including 3 new tests for version parsing, comparison, and asset name detection)cargo clippycleanclickhousectl update --checkreports current version statusclickhousectl updatedownloads and replaces binaryCloses #103
🤖 Generated with Claude Code