Skip to content

feat: add daemon mode and --json output#448

Merged
RetricSu merged 6 commits into
ckb-devrel:developfrom
humble-little-bear:feature/daemon-json-mode
Jul 8, 2026
Merged

feat: add daemon mode and --json output#448
RetricSu merged 6 commits into
ckb-devrel:developfrom
humble-little-bear:feature/daemon-json-mode

Conversation

@humble-little-bear

Copy link
Copy Markdown
Contributor

This PR adds daemon mode and agent-friendly JSON output as requested in #446.

Changes

  • Daemon mode: offckb node --daemon starts the CKB devnet (node + miner + RPC proxy) as a detached background process. It writes a PID file and logs to the devnet data folder.
  • JSON output: offckb --json [command] emits every log line as a structured JSON object, making the CLI easier to consume programmatically or from agents.
  • Added unit tests for both features.
  • Updated README with usage examples.

Usage

# Run devnet in the background
offckb node --daemon

# Stop the daemon
kill $(cat path/to/devnet/data/logs/daemon.pid)

# Structured JSON logs
offckb --json node
offckb --json node --daemon

Fixes #446

🤖 Generated with Claude Code

humble-little-bear and others added 6 commits July 7, 2026 07:45
- Add --daemon flag to offckb node to run the devnet in the background
- Add global --json flag for structured JSON log output
- Write daemon PID and logs to devnet data folder
- Add tests for logger JSON mode and node daemon spawning
- Update README with daemon and --json usage

Fixes ckb-devrel#446

Co-Authored-By: Claude <noreply@anthropic.com>
Add offckb node stop to terminate the devnet daemon started by
offckb node --daemon. It reads the PID file, sends SIGTERM, waits
for graceful shutdown, falls back to SIGKILL if needed, and removes
the PID file.

Also add tests and update README to mention node stop instead of
manual kill.

Co-Authored-By: Claude <noreply@anthropic.com>
- Run prettier so lint job's git diff --exit-code passes

- Use path.join in node-command tests so Windows path assertions pass

- Add changeset for daemon mode, --json output, and node stop command

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
- Reject duplicate daemon starts when PID file points to a live process.
- Verify target process identity before stopNode sends signals.
- Harden CLI entry resolution with OFFCKB_CLI_PATH fallback and file validation.
- Fix stopNode race condition between existsSync/readFileSync by reading once.
- Always clean up PID file even when signal delivery fails.
- Handle spawn sync exceptions, missing child.pid, and log dir creation failures.
- Use taskkill on Windows to terminate the daemon process tree.
- Distinguish EPERM vs ESRCH and surface clear error messages.

Co-Authored-By: Claude <noreply@anthropic.com>
- Assert the resolved script path so Windows backslash normalization passes.
- Mock WMIC output with the CommandLine= prefix required by the parser.
- Normalize process.platform to linux in stop tests for deterministic
  POSIX signal assertions; the Windows taskkill path is covered by the
  daemon spawn tests and integration tests.

Co-Authored-By: Claude <noreply@anthropic.com>
@RetricSu RetricSu merged commit 6f54296 into ckb-devrel:develop Jul 8, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add daemon mode for running CKB node and Agent-friendly

3 participants