mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 10:10:30 +08:00
httpd: Add SIGHUP config reloading
Enable hot-reloading of web configuration (pinned repos, avatar, banner, description) by sending SIGHUP to the process, eliminating the need for server restarts when updating these settings. Co-authored-by: Fintan Halpenny <fintan.halpenny@gmail.com>
This commit is contained in:
co-authored by
Fintan Halpenny
parent
ebe4e426e8
commit
7dfca539b4
@@ -92,7 +92,7 @@ async fn node_handler(State(ctx): State<Context>) -> impl IntoResponse {
|
||||
agent,
|
||||
config,
|
||||
node_state.to_string(),
|
||||
ctx.profile.config.web.clone(),
|
||||
ctx.web_config().read().await,
|
||||
);
|
||||
|
||||
Ok::<_, Error>(cached_response(response, 600))
|
||||
@@ -265,4 +265,37 @@ mod routes {
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_node_uses_reloadable_config() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let seed = seed(tmp.path());
|
||||
|
||||
{
|
||||
seed.web_config
|
||||
.update(|config| {
|
||||
config.description = Some("Test node description".to_string());
|
||||
config.avatar_url = Some("https://example.com/avatar.png".to_string());
|
||||
config.banner_url = Some("https://example.com/banner.png".to_string());
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
||||
let app = super::router(seed.clone())
|
||||
.layer(MockConnectInfo(SocketAddr::from(([127, 0, 0, 1], 8080))));
|
||||
let response = get(&app, "/node").await;
|
||||
|
||||
assert_eq!(response.status(), StatusCode::OK);
|
||||
let json_response = response.json().await;
|
||||
|
||||
assert_eq!(json_response["description"], json!("Test node description"));
|
||||
assert_eq!(
|
||||
json_response["avatarUrl"],
|
||||
json!("https://example.com/avatar.png")
|
||||
);
|
||||
assert_eq!(
|
||||
json_response["bannerUrl"],
|
||||
json!("https://example.com/banner.png")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user