Skip to content

feat(cli): add detach option to orx up and add orx down command - #415

Open
jyuan-dev wants to merge 2 commits into
alphaXiv:mainfrom
jyuan-dev:feat/detach-and-down
Open

jyuan-dev wants to merge 2 commits into
alphaXiv:mainfrom
jyuan-dev:feat/detach-and-down

Conversation

@jyuan-dev

Copy link
Copy Markdown
Contributor

Summary

This PR adds two complementary capabilities for managing the orx up dashboard server:

  1. Detached mode (-d, --detach) on orx up: Starts the dashboard server in the background as a detached process (using setsid), redirecting stdio to ~/.local/share/openresearch/orx-up.log, verifying health, and exiting immediately. This allows users to disconnect their terminal or SSH session while keeping the server running.
  2. orx down command: Stops running orx up dashboard instances regardless of PID. It dynamically detects instances via the local orx-up.json pidfile, loopback health endpoint probe, or process table scan, shutting them down gracefully through /api/down and escalating to SIGTERM/SIGKILL if needed.

Changes

  • src/main.rs:
    • Added -d, --detach option to UpArgs.
    • Added Command::Down(DownArgs) subcommand with --port, --remote, -f/--force, and --all flags.
  • src/commands/up.rs:
    • Handled args.detach by spawning a detached process with libc::setsid() and checking /api/health.
    • Added UpPidFile guard to record {pid, port} on startup.
    • Added routes POST /api/down and POST /api/shutdown for graceful shutdown.
    • Added "pid": std::process::id() to the /api/health response.
  • src/commands/down.rs:
    • Implemented dynamic target discovery (pidfile, health probing, /proc / ps process table inspection).
    • Implemented graceful shutdown with escalation.
    • Added remote delegation support via --remote <HOST>.
  • src/commands/up_remote.rs:
    • Exposed parse_remote_target for orx down --remote.

Test Plan

  • Unit tests: cargo test --bin orx cli_tests && cargo test --bin orx down::tests (all passed).
  • Integration test:
    • orx up --port 5899 -d starts the dashboard in the background and exits 0 immediately.
    • Verified curl http://127.0.0.1:5899/api/health returns ok.
    • orx down --port 5899 terminates the background server cleanly.
  • Verified cargo fmt --all --check and cargo clippy --all-targets -- -D warnings.

This branch has not been deployed

No deployments
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