Skip to content

Commit 53a4532

Browse files
committed
refactor: remove resource monitor initialization from ingest, query, and server handlers
1 parent 4578d0c commit 53a4532

File tree

4 files changed

+8
-19
lines changed

4 files changed

+8
-19
lines changed

src/handlers/http/modal/ingest_server.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,12 @@ impl ParseableServer for IngestServer {
133133
let (cancel_tx, cancel_rx) = oneshot::channel();
134134
thread::spawn(|| sync::handler(cancel_rx));
135135

136-
// Start resource monitor
137-
let (resource_shutdown_tx, resource_shutdown_rx) = oneshot::channel();
138-
resource_check::spawn_resource_monitor(resource_shutdown_rx);
139-
140136
tokio::spawn(airplane::server());
141137

142138
// Ingestors shouldn't have to deal with OpenId auth flow
143139
let result = self.start(shutdown_rx, prometheus.clone(), None).await;
144140
// Cancel sync jobs
145141
cancel_tx.send(()).expect("Cancellation should not fail");
146-
// Shutdown resource monitor
147-
let _ = resource_shutdown_tx.send(());
148142
if let Err(join_err) = startup_sync_handle.await {
149143
tracing::warn!("startup sync task panicked: {join_err}");
150144
}

src/handlers/http/modal/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use crate::{
4545
utils::get_node_id,
4646
};
4747

48-
use super::{audit, cross_origin_config, health_check, API_BASE_PATH, API_VERSION};
48+
use super::{audit, cross_origin_config, health_check, resource_check, API_BASE_PATH, API_VERSION};
4949

5050
pub mod ingest;
5151
pub mod ingest_server;
@@ -107,6 +107,10 @@ pub trait ParseableServer {
107107
&PARSEABLE.options.trusted_ca_certs_path,
108108
)?;
109109

110+
// Start resource monitor
111+
let (resource_shutdown_tx, resource_shutdown_rx) = oneshot::channel();
112+
resource_check::spawn_resource_monitor(resource_shutdown_rx);
113+
110114
// fn that creates the app
111115
let create_app_fn = move || {
112116
App::new()
@@ -142,6 +146,9 @@ pub trait ParseableServer {
142146

143147
health_check::shutdown().await;
144148

149+
// Shutdown resource monitor
150+
let _ = resource_shutdown_tx.send(());
151+
145152
// Initiate graceful shutdown
146153
info!("Graceful shutdown of HTTP server triggered");
147154
srv_handle.stop(true).await;

src/handlers/http/modal/query_server.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,19 +150,13 @@ impl ParseableServer for QueryServer {
150150
let (cancel_tx, cancel_rx) = oneshot::channel();
151151
thread::spawn(|| sync::handler(cancel_rx));
152152

153-
// Start resource monitor
154-
let (resource_shutdown_tx, resource_shutdown_rx) = oneshot::channel();
155-
resource_check::spawn_resource_monitor(resource_shutdown_rx);
156-
157153
tokio::spawn(airplane::server());
158154

159155
let result = self
160156
.start(shutdown_rx, prometheus.clone(), PARSEABLE.options.openid())
161157
.await?;
162158
// Cancel sync jobs
163159
cancel_tx.send(()).expect("Cancellation should not fail");
164-
// Shutdown resource monitor
165-
let _ = resource_shutdown_tx.send(());
166160
if let Err(join_err) = startup_sync_handle.await {
167161
tracing::warn!("startup sync task panicked: {join_err}");
168162
}

src/handlers/http/modal/server.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,6 @@ impl ParseableServer for Server {
152152
let (cancel_tx, cancel_rx) = oneshot::channel();
153153
thread::spawn(|| sync::handler(cancel_rx));
154154

155-
// Start resource monitor
156-
let (resource_shutdown_tx, resource_shutdown_rx) = oneshot::channel();
157-
resource_check::spawn_resource_monitor(resource_shutdown_rx);
158-
159155
if PARSEABLE.options.send_analytics {
160156
analytics::init_analytics_scheduler()?;
161157
}
@@ -168,8 +164,6 @@ impl ParseableServer for Server {
168164
.await;
169165
// Cancel sync jobs
170166
cancel_tx.send(()).expect("Cancellation should not fail");
171-
// Shutdown resource monitor
172-
let _ = resource_shutdown_tx.send(());
173167
if let Err(join_err) = startup_sync_handle.await {
174168
tracing::warn!("startup sync task panicked: {join_err}");
175169
}

0 commit comments

Comments
 (0)