1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-27 12:23:46 +03:00

prevent stats printing from interfering with cli proxy

This makes using stats with the mux possible again:

```
periodic_stat_logging = 10
```
This commit is contained in:
Wez Furlong 2020-01-13 08:56:38 -08:00
parent c989485a77
commit bb6251fad9
3 changed files with 16 additions and 3 deletions

View File

@ -22,9 +22,7 @@ pub struct GuiFrontEnd {
connection: Rc<Connection>,
}
lazy_static::lazy_static! {
static ref USE_OPENGL: AtomicBool = AtomicBool::new(true);
}
static USE_OPENGL: AtomicBool = AtomicBool::new(true);
pub fn is_opengl_enabled() -> bool {
USE_OPENGL.load(Ordering::Acquire)

View File

@ -792,6 +792,8 @@ fn run() -> anyhow::Result<()> {
// ourselves into basically netcat.
drop(client);
crate::stats::disable_stats_printing();
let front_end = FrontEndSelection::Null.try_new()?;
let mux = Rc::new(mux::Mux::new(None));
Mux::set_mux(&mux);

View File

@ -2,10 +2,13 @@ use crate::config::configuration;
use hdrhistogram::Histogram;
use metrics::{Key, Recorder};
use std::collections::HashMap;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex};
use std::time::{Duration, Instant};
use tabout::{tabulate_output, Alignment, Column};
static ENABLE_STAT_PRINT: AtomicBool = AtomicBool::new(true);
struct Inner {
histograms: HashMap<Key, Histogram<u64>>,
}
@ -14,6 +17,12 @@ fn pctile_latency(histogram: &Histogram<u64>, p: f64) -> Duration {
Duration::from_nanos(histogram.value_at_percentile(p))
}
/// Used to prevent the stats thread from trying to write to stderr
/// when we're running in proxy mode
pub fn disable_stats_printing() {
ENABLE_STAT_PRINT.store(false, Ordering::Acquire);
}
impl Inner {
fn run(inner: Arc<Mutex<Inner>>) {
let mut last_print = Instant::now();
@ -39,6 +48,10 @@ impl Inner {
loop {
std::thread::sleep(Duration::from_secs(10));
if !ENABLE_STAT_PRINT.load(Ordering::Acquire) {
break;
}
let seconds = configuration().periodic_stat_logging;
if seconds == 0 {
continue;