aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs11
-rw-r--r--src/metrics.rs5
2 files changed, 13 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index 93abcca..5ccc2fc 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -24,9 +24,12 @@ mod tls_util;
pub use df_consul as consul;
use proxy_config::ProxyConfig;
-#[cfg(feature = "dhat-heap")]
+#[cfg(not(target_env = "msvc"))]
+use tikv_jemallocator::Jemalloc;
+
+#[cfg(not(target_env = "msvc"))]
#[global_allocator]
-static ALLOC: dhat::Alloc = dhat::Alloc;
+static GLOBAL: Jemalloc = Jemalloc;
#[derive(StructOpt, Debug)]
#[structopt(name = "tricot")]
@@ -110,6 +113,7 @@ struct Opt {
pub warmup_cert_memory_store: bool,
}
+
#[tokio::main(flavor = "multi_thread", worker_threads = 10)]
async fn main() {
#[cfg(feature = "dhat-heap")]
@@ -210,7 +214,8 @@ async fn main() {
.then(|_| async { info!("HTTPS server exited") }),
);
- let dump_task = tokio::spawn(dump_config_on_change(rx_proxy_config, exit_signal.clone()));
+ let dump_task = tokio::spawn(dump_config_on_change(rx_proxy_config, exit_signal.clone()));
+
metrics_task.await.expect("Tokio task await failure");
http_task.await.expect("Tokio task await failure");
diff --git a/src/metrics.rs b/src/metrics.rs
index d9ad372..16720f0 100644
--- a/src/metrics.rs
+++ b/src/metrics.rs
@@ -70,6 +70,11 @@ impl MetricsServer {
debug!("{} {}", req.method(), req.uri());
let response = match (req.method(), req.uri().path()) {
+ (&Method::GET, "/hprof") => {
+ let buff = common_mem_prof::dump_profile().await.unwrap();
+ tokio::fs::write("memdump.hprof", buff).await.unwrap();
+ Response::builder().status(204).body(Body::from(vec![])).unwrap()
+ },
(&Method::GET, "/metrics") => {
let mut buffer = vec![];
let encoder = TextEncoder::new();