优化引入和文档
This commit is contained in:
+15
-5
@@ -6,7 +6,10 @@ use dht_crawler::prelude::*;
|
||||
use std::sync::Arc;
|
||||
use tracing_subscriber::EnvFilter;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
|
||||
#[cfg(feature = "metrics")]
|
||||
use metrics_exporter_prometheus::PrometheusBuilder;
|
||||
#[cfg(feature = "metrics")]
|
||||
use std::net::SocketAddr;
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
|
||||
@@ -18,6 +21,17 @@ async fn main() -> Result<()> {
|
||||
.with_ansi(true)
|
||||
.init();
|
||||
|
||||
// 初始化 Prometheus metrics 导出器
|
||||
#[cfg(feature = "metrics")]
|
||||
{
|
||||
let addr: SocketAddr = "0.0.0.0:9000".parse().expect("无效的地址");
|
||||
PrometheusBuilder::new()
|
||||
.with_http_listener(addr)
|
||||
.install()
|
||||
.expect("无法安装 Prometheus metrics 导出器");
|
||||
log::info!("📊 Prometheus metrics 导出器已启动,访问 http://localhost:9000/metrics");
|
||||
}
|
||||
|
||||
let options = DHTOptions {
|
||||
port: 12313,
|
||||
auto_metadata: true,
|
||||
@@ -67,10 +81,6 @@ async fn main() -> Result<()> {
|
||||
true
|
||||
});
|
||||
|
||||
server.set_filter(|_hash| {
|
||||
true
|
||||
});
|
||||
|
||||
// 启动监控任务
|
||||
let count_monitor = torrent_count.clone();
|
||||
tokio::spawn(async move {
|
||||
|
||||
Reference in New Issue
Block a user