-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixing telemetry server listen host (#1032) * Add `host` parameter for the telemetry server * Gracefully exit when telemetry service fails to start Co-authored-by: Romain Ruetschi <[email protected]>
- Loading branch information
Showing
5 changed files
with
59 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ log_level = 'info' | |
|
||
[telemetry] | ||
enabled = true | ||
host = '127.0.0.1' | ||
port = 3001 | ||
|
||
[[chains]] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,35 @@ | ||
pub mod server; | ||
pub mod state; | ||
|
||
use std::{sync::Arc, thread::JoinHandle}; | ||
use std::{ | ||
error::Error, | ||
net::{SocketAddr, ToSocketAddrs}, | ||
sync::Arc, | ||
thread::JoinHandle, | ||
}; | ||
|
||
pub use crate::state::TelemetryState; | ||
|
||
pub fn new_state() -> Arc<TelemetryState> { | ||
Arc::new(TelemetryState::default()) | ||
} | ||
|
||
pub fn spawn(port: u16, state: Arc<TelemetryState>) -> JoinHandle<()> { | ||
std::thread::spawn(move || server::run(state, port)) | ||
pub fn spawn<A>( | ||
address: A, | ||
state: Arc<TelemetryState>, | ||
) -> Result<(SocketAddr, JoinHandle<()>), Box<dyn Error + Send + Sync>> | ||
where | ||
A: ToSocketAddrs + Send + 'static, | ||
{ | ||
let server = server::listen(address, state); | ||
|
||
match server { | ||
Ok(server) => { | ||
let address = server.server_addr(); | ||
let handle = std::thread::spawn(move || server.run()); | ||
|
||
Ok((address, handle)) | ||
} | ||
Err(e) => Err(e), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters