Skip to content

Commit 2bc2b3e

Browse files
authored
fix: Windows failing build and querying (#978)
fixes #824
1 parent 5308808 commit 2bc2b3e

File tree

2 files changed

+53
-30
lines changed

2 files changed

+53
-30
lines changed

server/src/handlers/http/health_check.rs

+35-24
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ use actix_web::middleware::Next;
2525
use actix_web::{Error, HttpResponse};
2626
use lazy_static::lazy_static;
2727
use std::sync::Arc;
28-
use tokio::signal::unix::{signal, SignalKind};
28+
use tokio::signal::ctrl_c;
29+
2930
use tokio::sync::{oneshot, Mutex};
3031

3132
// Create a global variable to store signal status
@@ -52,35 +53,45 @@ pub async fn check_shutdown_middleware(
5253
}
5354

5455
pub async fn handle_signals(shutdown_signal: Arc<Mutex<Option<oneshot::Sender<()>>>>) {
55-
let mut sigterm =
56-
signal(SignalKind::terminate()).expect("Failed to set up SIGTERM signal handler");
57-
log::info!("Signal handler task started");
58-
59-
// Block until SIGTERM is received
60-
match sigterm.recv().await {
61-
Some(_) => {
62-
log::info!("Received SIGTERM signal at Readiness Probe Handler");
63-
64-
// Set the shutdown flag to true
65-
let mut shutdown_flag = SIGNAL_RECEIVED.lock().await;
66-
*shutdown_flag = true;
67-
68-
// Sync to local
69-
crate::event::STREAM_WRITERS.unset_all();
70-
71-
// Trigger graceful shutdown
72-
if let Some(shutdown_sender) = shutdown_signal.lock().await.take() {
73-
let _ = shutdown_sender.send(());
56+
#[cfg(windows)]
57+
{
58+
tokio::select! {
59+
_ = ctrl_c() => {
60+
log::info!("Received SIGINT signal at Readiness Probe Handler");
61+
shutdown(shutdown_signal).await;
7462
}
7563
}
76-
None => {
77-
log::info!("Signal handler received None, indicating an error or end of stream");
64+
}
65+
#[cfg(unix)]
66+
{
67+
use tokio::signal::unix::{signal, SignalKind};
68+
let mut sigterm = signal(SignalKind::terminate()).unwrap();
69+
tokio::select! {
70+
_ = ctrl_c() => {
71+
log::info!("Received SIGINT signal at Readiness Probe Handler");
72+
shutdown(shutdown_signal).await;
73+
},
74+
_ = sigterm.recv() => {
75+
log::info!("Received SIGTERM signal at Readiness Probe Handler");
76+
shutdown(shutdown_signal).await;
77+
}
7878
}
7979
}
80-
81-
log::info!("Signal handler task completed");
8280
}
8381

82+
async fn shutdown(shutdown_signal: Arc<Mutex<Option<oneshot::Sender<()>>>>) {
83+
// Set the shutdown flag to true
84+
let mut shutdown_flag = SIGNAL_RECEIVED.lock().await;
85+
*shutdown_flag = true;
86+
87+
// Sync to local
88+
crate::event::STREAM_WRITERS.unset_all();
89+
90+
// Trigger graceful shutdown
91+
if let Some(shutdown_sender) = shutdown_signal.lock().await.take() {
92+
let _ = shutdown_sender.send(());
93+
}
94+
}
8495
pub async fn readiness() -> HttpResponse {
8596
// Check the object store connection
8697
if CONFIG.storage().get_object_store().check().await.is_ok() {

server/src/query/stream_schema_provider.rs

+18-6
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,24 @@ fn partitioned_files(
237237
// object_store::path::Path doesn't automatically deal with Windows path separators
238238
// to do that, we are using from_absolute_path() which takes into consideration the underlying filesystem
239239
// before sending the file path to PartitionedFile
240-
let pf = if CONFIG.storage_name.eq("drive") {
241-
let file_path = object_store::path::Path::from_absolute_path(file_path).unwrap();
242-
PartitionedFile::new(file_path, file.file_size)
243-
} else {
244-
PartitionedFile::new(file_path, file.file_size)
245-
};
240+
// the github issue- https://github.com/parseablehq/parseable/issues/824
241+
// For some reason, the `from_absolute_path()` doesn't work for macos, hence the ugly solution
242+
// TODO: figure out an elegant solution to this
243+
let pf;
244+
245+
#[cfg(unix)]
246+
{
247+
pf = PartitionedFile::new(file_path, file.file_size);
248+
}
249+
#[cfg(windows)]
250+
{
251+
pf = if CONFIG.storage_name.eq("drive") {
252+
let file_path = object_store::path::Path::from_absolute_path(file_path).unwrap();
253+
PartitionedFile::new(file_path, file.file_size)
254+
} else {
255+
PartitionedFile::new(file_path, file.file_size)
256+
};
257+
}
246258

247259
partitioned_files[index].push(pf);
248260
columns.into_iter().for_each(|col| {

0 commit comments

Comments
 (0)