Skip to content

Commit

Permalink
f jd-server
Browse files Browse the repository at this point in the history
  • Loading branch information
jbesraa committed Aug 5, 2024
1 parent 15a9e17 commit 3255adc
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 36 deletions.
2 changes: 1 addition & 1 deletion roles/jd-client/config-examples/integration-tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ value = 1
authority_pubkey = "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72"
pool_address = "127.0.0.1:34254"

jd_address = "75.119.150.111:34264"
jd_address = "127.0.0.1:34264"
# Pool signature (string to be included in coinbase tx)
pool_signature = "Stratum v2 SRI Pool"

Expand Down
70 changes: 36 additions & 34 deletions roles/jd-server/src/lib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,44 +156,46 @@ pub async fn start_jd_server(config: Configuration) {

// Start the error handling loop
// See `./status.rs` and `utils/error_handling` for information on how this operates
loop {
let task_status = select! {
task_status = status_rx.recv() => task_status,
interrupt_signal = tokio::signal::ctrl_c() => {
match interrupt_signal {
Ok(()) => {
info!("Interrupt received");
},
Err(err) => {
error!("Unable to listen for interrupt signal: {}", err);
// we also shut down in case of error
},
task::spawn(async move {
loop {
let task_status = select! {
task_status = status_rx.recv() => task_status,
interrupt_signal = tokio::signal::ctrl_c() => {
match interrupt_signal {
Ok(()) => {
info!("Interrupt received");
},
Err(err) => {
error!("Unable to listen for interrupt signal: {}", err);
// we also shut down in case of error
},
}
break;
}
break;
}
};
let task_status: status::Status = task_status.unwrap();
};
let task_status: status::Status = task_status.unwrap();

match task_status.state {
// Should only be sent by the downstream listener
status::State::DownstreamShutdown(err) => {
error!(
"SHUTDOWN from Downstream: {}\nTry to restart the downstream listener",
err
);
}
status::State::TemplateProviderShutdown(err) => {
error!("SHUTDOWN from Upstream: {}\nTry to reconnecting or connecting to a new upstream", err);
break;
}
status::State::Healthy(msg) => {
info!("HEALTHY message: {}", msg);
}
status::State::DownstreamInstanceDropped(downstream_id) => {
warn!("Dropping downstream instance {} from jds", downstream_id);
match task_status.state {
// Should only be sent by the downstream listener
status::State::DownstreamShutdown(err) => {
error!(
"SHUTDOWN from Downstream: {}\nTry to restart the downstream listener",
err
);
}
status::State::TemplateProviderShutdown(err) => {
error!("SHUTDOWN from Upstream: {}\nTry to reconnecting or connecting to a new upstream", err);
break;
}
status::State::Healthy(msg) => {
info!("HEALTHY message: {}", msg);
}
status::State::DownstreamInstanceDropped(downstream_id) => {
warn!("Dropping downstream instance {} from jds", downstream_id);
}
}
}
}
});
}

pub fn get_coinbase_output(config: &Configuration) -> Result<Vec<TxOut>, Error> {
Expand Down
2 changes: 1 addition & 1 deletion roles/tests-integration/tests/jd_client_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async fn start_jd_client() -> (JobDeclaratorClient, jd_client::ProxyConfig) {
}

async fn init_jd_server() {
let config_path = "../jd-server/config-examples/jds-config-local-example.toml";
let config_path = "../jd-server/config-examples/jds-config-hosted-example.toml";
let config = std::fs::read_to_string(config_path).unwrap();
let config = toml::from_str::<jd_server::Configuration>(&config).expect("Failed to parse config");
jd_server::start_jd_server(config).await;
Expand Down

0 comments on commit 3255adc

Please sign in to comment.