mirror of
https://github.com/pezkuwichain/pezkuwi-telemetry.git
synced 2026-05-31 12:51:07 +00:00
Listen by default to the local interface and allows changing it (#246)
This commit is contained in:
@@ -16,6 +16,19 @@ cd backend
|
|||||||
cargo build --release
|
cargo build --release
|
||||||
./target/release/telemetry
|
./target/release/telemetry
|
||||||
```
|
```
|
||||||
|
|
||||||
|
By default, telemetry will listen on the local interface only (127.0.0.1) on port 8000. You may change both those values:
|
||||||
|
|
||||||
|
Use another port:
|
||||||
|
```
|
||||||
|
PORT=8123 telemetry
|
||||||
|
```
|
||||||
|
|
||||||
|
You may also change the the listening interface. This is especially required if you are using docker:
|
||||||
|
```
|
||||||
|
BIND=0.0.0.0 telemetry
|
||||||
|
```
|
||||||
|
|
||||||
### Terminal 2 - Frontend
|
### Terminal 2 - Frontend
|
||||||
```
|
```
|
||||||
yarn start:frontend
|
yarn start:frontend
|
||||||
|
|||||||
+4
-1
@@ -90,6 +90,8 @@ fn health(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Telemetry entry point. Listening by default on 127.0.0.1:8000.
|
||||||
|
/// This can be changed using the `PORT` and `BIND` ENV variables.
|
||||||
fn main() -> std::io::Result<()> {
|
fn main() -> std::io::Result<()> {
|
||||||
use web::{resource, get};
|
use web::{resource, get};
|
||||||
|
|
||||||
@@ -101,6 +103,7 @@ fn main() -> std::io::Result<()> {
|
|||||||
let locator = SyncArbiter::start(4, move || factory.create());
|
let locator = SyncArbiter::start(4, move || factory.create());
|
||||||
|
|
||||||
let port = std::env::var("PORT").ok().and_then(|v| v.parse().ok()).unwrap_or(8000u16);
|
let port = std::env::var("PORT").ok().and_then(|v| v.parse().ok()).unwrap_or(8000u16);
|
||||||
|
let bind_address = std::env::var("BIND").ok().unwrap_or("127.0.0.1".to_string());
|
||||||
|
|
||||||
HttpServer::new(move || {
|
HttpServer::new(move || {
|
||||||
App::new()
|
App::new()
|
||||||
@@ -115,7 +118,7 @@ fn main() -> std::io::Result<()> {
|
|||||||
.service(resource("/health").route(get().to_async(health)))
|
.service(resource("/health").route(get().to_async(health)))
|
||||||
.service(resource("/health/").route(get().to_async(health)))
|
.service(resource("/health/").route(get().to_async(health)))
|
||||||
})
|
})
|
||||||
.bind(format!("0.0.0.0:{}", port))?
|
.bind(format!("{}:{}", bind_address, port))?
|
||||||
.start();
|
.start();
|
||||||
|
|
||||||
sys.run()
|
sys.run()
|
||||||
|
|||||||
Reference in New Issue
Block a user