Skip to content

Commit 3ae15e6

Browse files
committed
Merge branch 'restart_auditor_webservice_stable' into stable
2 parents 412b998 + 979e03c commit 3ae15e6

File tree

4 files changed

+63
-37
lines changed

4 files changed

+63
-37
lines changed

CHANGELOG.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313

1414
#### Changed
1515

16+
- The auditor's webservice has new endpoints that allow it to be restarted or terminated
17+
18+
## 2024-10-07
19+
20+
### Network
21+
22+
#### Changed
23+
1624
- Increase chunk size to 4MB with node size remaining at 32GB
1725
- Bootstrap peer parsing in CI was changed to accommodate new log format in libp2p
1826

1927
### Node Manager
2028

2129
#### Added
2230

23-
- The `add` command has new `--max-log-files` and `--max-archived-log-files` arguments to support capping node log output
31+
- The `add` command has new `--max-log-files` and `--max-archived-log-files` arguments to support
32+
capping node log output
2433

2534
#### Fixed
2635

@@ -30,7 +39,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3039

3140
### Added
3241

33-
- Increased logging related to app configuration. This could help solving issues on launchpad start up.
42+
- Increased logging related to app configuration. This could help solving issues on launchpad start
43+
up.
3444

3545
## 2024-10-03
3646

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sn_auditor/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
authors = ["MaidSafe Developers <dev@maidsafe.net>"]
33
description = "Safe Network Auditor"
44
name = "sn_auditor"
5-
version = "0.3.3"
5+
version = "0.3.4"
66
edition = "2021"
77
homepage = "https://maidsafe.net"
88
repository = "https://github.com/maidsafe/safe_network"

sn_auditor/src/main.rs

Lines changed: 49 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -262,43 +262,59 @@ async fn initialize_background_spend_dag_collection(
262262
}
263263

264264
async fn start_server(dag: SpendDagDb) -> Result<()> {
265-
let server = Server::http("0.0.0.0:4242").expect("Failed to start server");
266-
info!("Starting dag-query server listening on port 4242...");
267-
for request in server.incoming_requests() {
268-
info!(
269-
"Received request! method: {:?}, url: {:?}",
270-
request.method(),
271-
request.url(),
272-
);
273-
274-
// Dispatch the request to the appropriate handler
275-
let response = match request.url() {
276-
"/" => routes::spend_dag_svg(&dag),
277-
s if s.starts_with("/spend/") => routes::spend(&dag, &request).await,
278-
s if s.starts_with("/add-participant/") => {
279-
routes::add_participant(&dag, &request).await
280-
}
281-
"/beta-rewards" => routes::beta_rewards(&dag).await,
282-
_ => routes::not_found(),
283-
};
265+
loop {
266+
let server = Server::http("0.0.0.0:4242").expect("Failed to start server");
267+
info!("Starting dag-query server listening on port 4242...");
268+
for request in server.incoming_requests() {
269+
info!(
270+
"Received request! method: {:?}, url: {:?}",
271+
request.method(),
272+
request.url(),
273+
);
284274

285-
// Send a response to the client
286-
match response {
287-
Ok(res) => {
288-
let _ = request
289-
.respond(res)
290-
.map_err(|err| eprintln!("Failed to send response: {err}"));
291-
}
292-
Err(e) => {
293-
eprint!("Sending error to client: {e}");
294-
let res = Response::from_string(format!("Error: {e}")).with_status_code(500);
295-
let _ = request
296-
.respond(res)
297-
.map_err(|err| eprintln!("Failed to send error response: {err}"));
275+
// Dispatch the request to the appropriate handler
276+
let response = match request.url() {
277+
"/" => routes::spend_dag_svg(&dag),
278+
s if s.starts_with("/spend/") => routes::spend(&dag, &request).await,
279+
s if s.starts_with("/add-participant/") => {
280+
routes::add_participant(&dag, &request).await
281+
}
282+
"/beta-rewards" => routes::beta_rewards(&dag).await,
283+
"/restart" => {
284+
info!("Restart auditor web service as to client's request");
285+
break;
286+
}
287+
"/terminate" => {
288+
info!("Terminate auditor web service as to client's request");
289+
return Ok(());
290+
}
291+
_ => routes::not_found(),
292+
};
293+
294+
// Send a response to the client
295+
match response {
296+
Ok(res) => {
297+
info!("Sending response to client");
298+
let _ = request.respond(res).map_err(|err| {
299+
warn!("Failed to send response: {err}");
300+
eprintln!("Failed to send response: {err}")
301+
});
302+
}
303+
Err(e) => {
304+
eprint!("Sending error to client: {e}");
305+
let res = Response::from_string(format!("Error: {e}")).with_status_code(500);
306+
let _ = request.respond(res).map_err(|err| {
307+
warn!("Failed to send error response: {err}");
308+
eprintln!("Failed to send error response: {err}")
309+
});
310+
}
298311
}
299312
}
313+
// Reaching this point indicates a restarting of auditor web service
314+
// Sleep for a while to allowing OS cleanup and settlement.
315+
drop(server);
316+
std::thread::sleep(std::time::Duration::from_secs(10));
300317
}
301-
Ok(())
302318
}
303319

304320
// get the data dir path for auditor

0 commit comments

Comments
 (0)