Skip to content

Commit 55b9e01

Browse files
committed
download and server fixes for mac and windows
1 parent 94a9fbd commit 55b9e01

4 files changed

Lines changed: 19 additions & 36 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,6 @@ jobs:
189189
- os: macos-latest
190190
artifact-name: stackql-deploy-macos-arm64
191191
archive: tar.gz
192-
- os: macos-13
193-
artifact-name: stackql-deploy-macos-x86_64
194-
archive: tar.gz
195192
runs-on: ${{ matrix.os }}
196193
steps:
197194
- uses: actions/download-artifact@v8

.github/workflows/release.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,6 @@ jobs:
149149
- os: macos-latest
150150
artifact-name: stackql-deploy-macos-arm64
151151
archive: tar.gz
152-
- os: macos-13
153-
artifact-name: stackql-deploy-macos-x86_64
154-
archive: tar.gz
155152
runs-on: ${{ matrix.os }}
156153
steps:
157154
- uses: actions/download-artifact@v8

src/utils/download.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,11 @@ fn extract_binary(
152152
match get_platform() {
153153
Platform::MacOS => {
154154
// For macOS, we need to use pkgutil
155+
// pkgutil --expand-full requires the destination directory to NOT exist
155156
let unpacked_dir = dest_dir.join("stackql_unpacked");
156157
if unpacked_dir.exists() {
157158
fs::remove_dir_all(&unpacked_dir).map_err(AppError::IoError)?;
158159
}
159-
fs::create_dir_all(&unpacked_dir).map_err(AppError::IoError)?;
160160

161161
let output = Command::new("pkgutil")
162162
.arg("--expand-full")

src/utils/server.rs

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -93,48 +93,37 @@ pub fn find_all_running_servers() -> Vec<RunningServer> {
9393
let mut running_servers = Vec::new();
9494

9595
if cfg!(target_os = "windows") {
96-
// Use WMIC to get stackql processes with their command lines and PIDs
97-
let output = ProcessCommand::new("wmic")
96+
// Use PowerShell Get-CimInstance to get stackql processes with command lines
97+
let output = ProcessCommand::new("powershell")
9898
.args([
99-
"process",
100-
"where",
101-
"name='stackql.exe'",
102-
"get",
103-
"ProcessId,CommandLine",
104-
"/format:list",
99+
"-NoProfile",
100+
"-Command",
101+
"Get-CimInstance Win32_Process -Filter \"Name='stackql.exe'\" | ForEach-Object { \"PID=$($_.ProcessId) CMD=$($_.CommandLine)\" }",
105102
])
106103
.output();
107104

108105
if let Ok(output) = output {
109106
let output_str = String::from_utf8_lossy(&output.stdout);
110-
let mut current_cmdline = String::new();
111-
let mut current_pid: Option<u32> = None;
112-
113107
for line in output_str.lines() {
114108
let line = line.trim();
115-
if let Some(cmdline) = line.strip_prefix("CommandLine=") {
116-
current_cmdline = cmdline.to_string();
117-
} else if let Some(pid_str) = line.strip_prefix("ProcessId=") {
118-
current_pid = pid_str.trim().parse().ok();
119-
}
120-
121-
// When we have both values, emit a server entry
122-
if let Some(pid) = current_pid {
123-
if !current_cmdline.is_empty() {
124-
if let Some(port) = extract_port_from_cmdline(&current_cmdline) {
125-
debug!(
126-
"find_all_running_servers (Windows): PID {} -> port {} (cmdline: {})",
127-
pid, port, current_cmdline
128-
);
129-
running_servers.push(RunningServer { pid, port });
109+
if let Some(rest) = line.strip_prefix("PID=") {
110+
if let Some(space_pos) = rest.find(" CMD=") {
111+
let pid_str = &rest[..space_pos];
112+
let cmdline = &rest[space_pos + 5..];
113+
if let Ok(pid) = pid_str.parse::<u32>() {
114+
if let Some(port) = extract_port_from_cmdline(cmdline) {
115+
debug!(
116+
"find_all_running_servers (Windows): PID {} -> port {}",
117+
pid, port
118+
);
119+
running_servers.push(RunningServer { pid, port });
120+
}
130121
}
131-
current_cmdline.clear();
132-
current_pid = None;
133122
}
134123
}
135124
}
136125
} else {
137-
debug!("find_all_running_servers: wmic command failed, falling back to tasklist");
126+
debug!("find_all_running_servers: PowerShell command failed");
138127
}
139128
} else {
140129
let output = ProcessCommand::new("pgrep")

0 commit comments

Comments
 (0)