g3 console initial cut + error doesnt kill auto
This commit is contained in:
38
crates/g3-console/examples/debug_detector.rs
Normal file
38
crates/g3-console/examples/debug_detector.rs
Normal file
@@ -0,0 +1,38 @@
|
||||
use sysinfo::{System, Pid};
|
||||
|
||||
fn main() {
|
||||
let mut sys = System::new_all();
|
||||
sys.refresh_processes();
|
||||
|
||||
println!("Looking for g3 processes...");
|
||||
|
||||
for (pid, process) in sys.processes() {
|
||||
let cmd = process.cmd();
|
||||
if cmd.is_empty() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let cmd_str = cmd.join(" ");
|
||||
|
||||
// Check if this contains 'g3'
|
||||
if cmd_str.contains("g3") {
|
||||
println!("\nFound potential g3 process:");
|
||||
println!(" PID: {}", pid);
|
||||
println!(" Name: {}", process.name());
|
||||
println!(" Cmd[0]: {:?}", cmd.get(0));
|
||||
println!(" Full cmd: {:?}", cmd);
|
||||
|
||||
// Check detection logic
|
||||
let is_g3_binary = cmd.get(0).map(|s| s.ends_with("g3")).unwrap_or(false);
|
||||
let is_cargo_run = cmd.get(0).map(|s| s.contains("cargo")).unwrap_or(false)
|
||||
&& cmd.iter().any(|s| s == "run" || s.contains("g3"));
|
||||
|
||||
println!(" is_g3_binary: {}", is_g3_binary);
|
||||
println!(" is_cargo_run: {}", is_cargo_run);
|
||||
|
||||
// Check workspace
|
||||
let has_workspace = cmd.iter().any(|s| s == "--workspace" || s == "-w");
|
||||
println!(" has_workspace: {}", has_workspace);
|
||||
}
|
||||
}
|
||||
}
|
||||
19
crates/g3-console/examples/test_api.rs
Normal file
19
crates/g3-console/examples/test_api.rs
Normal file
@@ -0,0 +1,19 @@
|
||||
extern crate g3_console;
|
||||
use g3_console::process::ProcessDetector;
|
||||
|
||||
fn main() {
|
||||
let mut detector = ProcessDetector::new();
|
||||
|
||||
match detector.detect_instances() {
|
||||
Ok(instances) => {
|
||||
println!("Found {} instances:", instances.len());
|
||||
for instance in instances {
|
||||
println!(" - PID: {}, Workspace: {:?}, Type: {:?}",
|
||||
instance.pid, instance.workspace, instance.instance_type);
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("Error: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
19
crates/g3-console/examples/test_detector.rs
Normal file
19
crates/g3-console/examples/test_detector.rs
Normal file
@@ -0,0 +1,19 @@
|
||||
use sysinfo::{System, Pid};
|
||||
|
||||
fn main() {
|
||||
let mut sys = System::new_all();
|
||||
sys.refresh_processes();
|
||||
|
||||
// Test with known PIDs
|
||||
let pids = vec![68123, 72749];
|
||||
|
||||
for pid_num in pids {
|
||||
let pid = Pid::from_u32(pid_num);
|
||||
if let Some(process) = sys.process(pid) {
|
||||
println!("\nPID: {}", pid_num);
|
||||
println!("Name: {}", process.name());
|
||||
println!("Cmd: {:?}", process.cmd());
|
||||
println!("Exe: {:?}", process.exe());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user