daemon: add run-agent RPC for queuing agent jobs
Adds `poc-memory daemon run-agent <type> <count>` CLI command that sends an RPC to the daemon to queue agent runs, instead of spawning separate processes. Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
a505b9384e
commit
7d6ebbacab
2 changed files with 16 additions and 0 deletions
|
|
@ -1277,6 +1277,17 @@ pub fn rpc_consolidate() -> Result<(), String> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn rpc_run_agent(agent: &str, count: usize) -> Result<(), String> {
|
||||||
|
let cmd = format!("run-agent {} {}", agent, count);
|
||||||
|
match send_rpc(&cmd) {
|
||||||
|
Some(resp) => {
|
||||||
|
println!("{}", resp.trim());
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
None => Err("Daemon not running.".into()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn read_status_socket() -> Option<DaemonStatus> {
|
fn read_status_socket() -> Option<DaemonStatus> {
|
||||||
use std::io::Read as _;
|
use std::io::Read as _;
|
||||||
use std::os::unix::net::UnixStream;
|
use std::os::unix::net::UnixStream;
|
||||||
|
|
|
||||||
|
|
@ -2423,6 +2423,11 @@ fn cmd_daemon(sub: Option<&str>, args: &[String]) -> Result<(), String> {
|
||||||
}
|
}
|
||||||
Some("install") => daemon::install_service(),
|
Some("install") => daemon::install_service(),
|
||||||
Some("consolidate") => daemon::rpc_consolidate(),
|
Some("consolidate") => daemon::rpc_consolidate(),
|
||||||
|
Some("run-agent") | Some("run") => {
|
||||||
|
let agent = args.first().map(|s| s.as_str()).unwrap_or("replay");
|
||||||
|
let count: usize = args.get(1).and_then(|s| s.parse().ok()).unwrap_or(1);
|
||||||
|
daemon::rpc_run_agent(agent, count)
|
||||||
|
}
|
||||||
Some("tui") => tui::run_tui(),
|
Some("tui") => tui::run_tui(),
|
||||||
Some(other) => Err(format!("unknown daemon subcommand: {}", other)),
|
Some(other) => Err(format!("unknown daemon subcommand: {}", other)),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue