Add server process management with named instances#15
Merged
Conversation
Introduce `chv server` command group for managing multiple named ClickHouse server instances, replacing the old `chv run server`. Key changes: - New `src/server.rs` module for process tracking, port management, and server lifecycle (start/stop/list/remove) - Each server gets its own data directory at `.clickhouse/servers/<name>/data/` - Servers default to background mode with `--foreground` (`-F`/`--fg`) flag - Auto-assigns free ports when defaults (8123/9000) are in use; explicit `--http-port` and `--tcp-port` flags for manual control - Named servers: "default" for first, random adjective-noun for subsequent, or explicit `--name` for stable identity - PID tracking with health checks, SIGTERM→SIGKILL shutdown sequence - `chv server list` shows both running and stopped servers - `chv server stop-all` for bulk shutdown - `chv server remove` to delete stopped server data - `chv run` simplified to only handle client, local, and --sql - New error variants: ServerNotRunning, ServerNotFound, ServerAlreadyRunning Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Document the new `chv server` command group including start, list, stop, stop-all, and remove subcommands. Cover server naming, auto port assignment, foreground mode, and per-server data directories. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
eac07ee to
a1da230
Compare
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
chv servercommand group replacingchv run server, with subcommands:start,list,stop,stop-all,remove.clickhouse/servers/<name>/data/, enabling multiple isolated servers running simultaneously--namefor stable identities--http-portand--tcp-portflags for manual control--foreground(-F/--fg) to run in foregroundchv server listshows both running and stopped servers by scanning data directorieschv runsimplified — now only handlesclient,local, and--sqlNew commands
chv server startchv server start --name devchv server start --http-port 8124chv server start --foregroundchv server listchv server stop <name>chv server stop-allchv server remove <name>Breaking changes
chv run serveris removed — usechv server startinstead.clickhouse/{version}/to.clickhouse/servers/<name>/data/Test plan
chv server start— starts "default" server in background, prints PID and portschv server startagain — auto-generates random name, auto-assigns free portschv server start --name test— starts named serverchv server list— shows running and stopped servers with statuschv server stop default— stops the default serverchv server list— default now shows as [stopped]chv server start --name default— restarts the stopped serverchv server stop-all— stops all running serverschv server remove test— deletes stopped server datachv server start --foreground— runs in foreground, Ctrl-C exits cleanlychv server start --http-port 9123 --tcp-port 9100— uses explicit portschv run --sql "SELECT 1"— still workschv run client/chv run local— still works🤖 Generated with Claude Code