Skip to content

Commit 5e33f15

Browse files
committed
Allow redirect as healthy response
1 parent c5a2268 commit 5e33f15

4 files changed

Lines changed: 27 additions & 14 deletions

File tree

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ axum = { version = "0.8", features = ["macros", "ws"] }
99
axum-extra = { version = "0.12", default-features = false, features = [
1010
"cookie-private",
1111
] }
12-
bytes = "1.8"
12+
bytes = "1.11"
1313
chrono = { version = "0.4", features = ["serde"] }
1414
config = "0.15"
1515
constant_time_eq = "0.4"
1616
cookie = "0.18"
1717
futures = "0.3"
18-
hyper = { version = "1.0", features = ["full"] }
18+
hyper = { version = "1.9", features = ["full"] }
1919
hyper-util = { version = "0.1", features = ["client-legacy"] }
2020
oauth2 = "5.0"
2121
parking_lot = "0.12"

src/monitor.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,15 @@ impl SystemMonitor {
3939
// Send regular updates to the event manager and thereby the connected clients
4040
pub async fn send_updates(state: AppState) {
4141
let mut system = System::new_all();
42-
let last_cleanup = std::time::Instant::now();
42+
let mut last_cleanup = std::time::Instant::now();
4343

4444
loop {
4545
// if the last cleanup was more than a day ago, run cleanup
46-
if last_cleanup.elapsed().as_secs() > 24 * 60 * 60
47-
&& let Err(e) = executable::remove_unused_executables(state.clone()).await
48-
{
49-
error!("Failed to remove unused executables: {e:?}");
46+
if last_cleanup.elapsed().as_secs() > 24 * 60 * 60 {
47+
if let Err(e) = executable::remove_unused_executables(state.clone()).await {
48+
error!("Failed to remove unused executables: {e:?}");
49+
}
50+
last_cleanup = std::time::Instant::now();
5051
}
5152

5253
system.refresh_all();

src/services.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl ServiceManager {
3636
.map(|service| service.into())
3737
.collect::<Vec<ServiceData>>();
3838

39-
services.sort_by(|a, b| b.created_at.cmp(&a.created_at));
39+
services.sort_by_key(|s| std::cmp::Reverse(s.created_at));
4040

4141
services
4242
}
@@ -91,13 +91,14 @@ impl ServiceManager {
9191

9292
let client = reqwest::Client::builder()
9393
.timeout(Duration::from_secs(1))
94+
.redirect(reqwest::redirect::Policy::none())
9495
.build()?;
9596

9697
for i in 0..10 {
9798
info!("Checking ({i}) service on port {}", port);
9899

99100
if let Ok(response) = client.get(format!("http://127.0.0.1:{port}/")).send().await
100-
&& response.status().is_success()
101+
&& (response.status().is_success() || response.status().is_redirection())
101102
{
102103
self.set_service_state(name, ServiceState::Running, None);
103104

src/upload.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,22 @@ pub async fn upload_handler(
9191
executables: state.services.get_executables(),
9292
});
9393

94-
if state.github.update(state.config).await.is_ok() {
95-
state.channel.send(Event::GithubState {
96-
payload: state.github.get_state(),
97-
});
98-
}
94+
// update GitHub state 1 minute after the upload
95+
let delayed_state = state.clone();
96+
tokio::spawn(async move {
97+
tokio::time::sleep(std::time::Duration::from_secs(60)).await;
98+
99+
if delayed_state
100+
.github
101+
.update(delayed_state.config)
102+
.await
103+
.is_ok()
104+
{
105+
delayed_state.channel.send(Event::GithubState {
106+
payload: delayed_state.github.get_state(),
107+
});
108+
}
109+
});
99110

100111
Ok((
101112
StatusCode::CREATED,

0 commit comments

Comments
 (0)