Skip to content

feat(cli): add gateway restart command#108

Merged
owainlewis merged 2 commits into
mainfrom
codex/restart-gateway-command
Jul 16, 2026
Merged

feat(cli): add gateway restart command#108
owainlewis merged 2 commits into
mainfrom
codex/restart-gateway-command

Conversation

@owainlewis

@owainlewis owainlewis commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • add push restart for managed gateway services
  • restart com.owainlewis.push with launchd on macOS and push.service with user systemd on Linux
  • document config reload behavior and cover service-manager execution and failures

Why

Config changes currently require users to remember the platform-specific service-manager command. This adds one Push command that restarts the documented managed gateway.

Test plan

  • cargo fmt --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo test (264 tests passed)
  • uv run --with-requirements requirements-docs.txt mkdocs build --strict
  • git diff --check
  • independent subagent review, with all findings addressed and no remaining findings

Risks

The command targets the documented fixed launchd label and systemd user unit. Custom service names are not selected by --config.

Related issue

None.

Summary by CodeRabbit

  • New Features

    • Added the push restart command to restart the managed Push gateway on macOS and Linux.
    • Added clear success and error feedback when restarting the gateway.
  • Documentation

    • Updated CLI, service, and Telegram setup guides with restart instructions.
    • Clarified configuration validation and foreground operation workflows.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@owainlewis, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 51 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 087340fb-2ecb-4edd-8742-caed8cb19c79

📥 Commits

Reviewing files that changed from the base of the PR and between ff460e1 and 17b627d.

📒 Files selected for processing (1)
  • tests/init_cli.rs
📝 Walkthrough

Walkthrough

Adds a cross-platform push restart CLI command that restarts the managed gateway through macOS launchd or Linux systemd, with command parsing, execution error handling, tests, and updated operational documentation.

Changes

Gateway restart command

Layer / File(s) Summary
Platform restart implementation
src/restart.rs
Builds macOS launchctl and Linux systemctl restart commands, validates macOS user IDs, reports execution failures, and tests command construction and outcomes.
CLI command integration
src/main.rs, tests/init_cli.rs
Adds parsing and dispatch for restart, preserves the config path during parsing, and verifies platform service-manager invocation.
Restart usage documentation
docs/reference/cli.md, docs/services.md, docs/telegram.md
Documents the command, service targets, config behavior, and restart steps for managed and foreground gateway operation.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PushCLI
  participant restart_gateway
  participant ServiceManager
  PushCLI->>restart_gateway: Parse and dispatch "restart"
  restart_gateway->>ServiceManager: Restart launchd or systemd gateway
  ServiceManager-->>restart_gateway: Return exit status
  restart_gateway-->>PushCLI: Print success or return error
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a gateway restart command.
Description check ✅ Passed The description follows the required template and includes Summary, Why, Test plan, Risks, and Related issue.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/restart-gateway-command

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 16, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds a push restart command that restarts the managed gateway service using the platform's native service manager — launchctl kickstart -k on macOS and systemctl --user restart on Linux. The implementation is clean: command construction and execution are decoupled through an injected runner callback, user ID validation prevents malformed launchctl paths, and documentation is updated across three pages.

  • src/restart.rs: New module builds the correct PlatformCommand per OS, runs id -u on macOS to get the UID for the launchd target, validates the output is digits-only, and surfaces clear error messages on spawn or non-zero exit.
  • tests/init_cli.rs: Integration test stubs the service manager binary via PATH prepending and captures arguments via an env-variable-named output file, avoiding shell-quoting problems.
  • Docs: cli.md, services.md, and telegram.md are updated to advertise push restart after config edits, replacing the previously scattered platform-specific commands.

Confidence Score: 5/5

Safe to merge — the new restart command is well-scoped, correctly constructs the platform-specific service manager invocation, and is covered by both unit and integration tests.

The implementation is straightforward: hardcoded service names, digit-only UID validation before embedding in a launchctl path, and a runner-injection pattern that keeps execution and construction testable independently. No config is read or written by this command, so the risk surface is narrow. Documentation changes are accurate and consistent with the code.

No files require special attention.

Important Files Changed

Filename Overview
src/restart.rs New module implementing cross-platform gateway restart; uses injection-friendly runner callback for testability, validates user ID digits before embedding in launchctl path, and cleanly separates command construction from execution.
src/main.rs Wires up the new Restart command variant, parser arm, and error message; change is minimal and consistent with existing patterns.
tests/init_cli.rs Adds an integration test that stubs out the platform service manager via PATH injection and verifies argument ordering for both macOS and Linux; env-variable-based capture avoids any shell-quoting issues with the temp-dir path.
docs/reference/cli.md Documents the new restart command in the command table and examples, and adds a note clarifying that --config does not override the service definition for this command.
docs/services.md Adds push restart usage after the config-edit step for both the macOS and Linux service sections.
docs/telegram.md Simplifies the Telegram setup instructions by replacing platform-specific restart commands with the new push restart command.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant User
    participant push CLI
    participant effective_user_id
    participant id_cmd as id (macOS only)
    participant svc_mgr as launchctl / systemctl

    User->>push CLI: push restart
    push CLI->>effective_user_id: get UID (macOS only)
    effective_user_id->>id_cmd: id -u
    id_cmd-->>effective_user_id: "501"
    effective_user_id-->>push CLI: Some("501")
    push CLI->>push CLI: build PlatformCommand
    Note over push CLI: macOS: launchctl kickstart -k gui/501/com.owainlewis.push<br/>Linux: systemctl --user restart push.service
    push CLI->>svc_mgr: spawn process
    svc_mgr-->>push CLI: exit status
    alt success
        push CLI-->>User: Restarted the Push gateway.
    else failure
        push CLI-->>User: error with command + exit status
    end
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant User
    participant push CLI
    participant effective_user_id
    participant id_cmd as id (macOS only)
    participant svc_mgr as launchctl / systemctl

    User->>push CLI: push restart
    push CLI->>effective_user_id: get UID (macOS only)
    effective_user_id->>id_cmd: id -u
    id_cmd-->>effective_user_id: "501"
    effective_user_id-->>push CLI: Some("501")
    push CLI->>push CLI: build PlatformCommand
    Note over push CLI: macOS: launchctl kickstart -k gui/501/com.owainlewis.push<br/>Linux: systemctl --user restart push.service
    push CLI->>svc_mgr: spawn process
    svc_mgr-->>push CLI: exit status
    alt success
        push CLI-->>User: Restarted the Push gateway.
    else failure
        push CLI-->>User: error with command + exit status
    end
Loading

Reviews (2): Last reviewed commit: "fix(test): avoid shell path interpolatio..." | Re-trigger Greptile

Comment thread tests/init_cli.rs
@owainlewis
owainlewis merged commit 8b9cbbf into main Jul 16, 2026
5 checks passed
@owainlewis
owainlewis deleted the codex/restart-gateway-command branch July 16, 2026 09:56
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.

1 participant