mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-02-25 18:55:38 -06:00
improve dht consensus checking and low level networking
This commit is contained in:
@@ -89,11 +89,12 @@ pub struct CmdlineArgs {
|
||||
flame: Option<OsString>,
|
||||
|
||||
/// Turn on perfetto tracing (experimental)
|
||||
#[cfg(unix)]
|
||||
#[arg(long, hide = true, value_name = "PATH", num_args=0..=1, require_equals=true, default_missing_value = "")]
|
||||
perfetto: Option<OsString>,
|
||||
|
||||
/// Run as an extra daemon on the same machine for testing purposes, specify a number greater than zero to offset the listening ports
|
||||
#[arg(long)]
|
||||
#[arg(short('n'), long)]
|
||||
subnode_index: Option<u16>,
|
||||
|
||||
/// Only generate a new keypair and print it
|
||||
@@ -235,6 +236,7 @@ fn main() -> EyreResult<()> {
|
||||
settingsrw.logging.flame.enabled = true;
|
||||
settingsrw.logging.flame.path = flame;
|
||||
}
|
||||
#[cfg(unix)]
|
||||
if let Some(perfetto) = args.perfetto {
|
||||
let perfetto = if perfetto.is_empty() {
|
||||
Settings::get_default_perfetto_path(settingsrw.testing.subnode_index)
|
||||
@@ -418,13 +420,11 @@ fn main() -> EyreResult<()> {
|
||||
|
||||
run_veilid_server(settings, server_mode, veilid_logs).await
|
||||
})
|
||||
.map(|v| {
|
||||
.inspect(|_v| {
|
||||
println!("{}", success);
|
||||
v
|
||||
})
|
||||
.map_err(|e| {
|
||||
.inspect_err(|_e| {
|
||||
println!("{}", failure);
|
||||
e
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -884,6 +884,7 @@ impl Settings {
|
||||
}
|
||||
|
||||
/// Determine default perfetto output path
|
||||
#[cfg(unix)]
|
||||
pub fn get_default_perfetto_path(subnode_index: u16) -> PathBuf {
|
||||
std::env::temp_dir().join(if subnode_index == 0 {
|
||||
"veilid-server.pftrace".to_owned()
|
||||
@@ -892,7 +893,7 @@ impl Settings {
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[cfg_attr(windows, expect(dead_code))]
|
||||
fn get_or_create_private_directory<P: AsRef<Path>>(path: P, group_read: bool) -> bool {
|
||||
let path = path.as_ref();
|
||||
if !path.is_dir()
|
||||
@@ -904,7 +905,7 @@ impl Settings {
|
||||
true
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[cfg_attr(windows, expect(dead_code))]
|
||||
fn get_default_directory(subpath: &str) -> PathBuf {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
|
||||
@@ -6,7 +6,6 @@ use console_subscriber::ConsoleLayer;
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "opentelemetry-otlp")] {
|
||||
use opentelemetry::*;
|
||||
use opentelemetry_sdk::*;
|
||||
use opentelemetry_otlp::WithExportConfig;
|
||||
}
|
||||
@@ -18,6 +17,7 @@ use std::path::*;
|
||||
use std::sync::Arc;
|
||||
use tracing_appender::*;
|
||||
use tracing_flame::FlameLayer;
|
||||
#[cfg(unix)]
|
||||
use tracing_perfetto::PerfettoLayer;
|
||||
use tracing_subscriber::prelude::*;
|
||||
use tracing_subscriber::*;
|
||||
@@ -63,12 +63,27 @@ impl VeilidLogs {
|
||||
|
||||
// Terminal logger
|
||||
if settingsr.logging.terminal.enabled {
|
||||
let timer = time::format_description::parse("[hour]:[minute]:[second]")
|
||||
.expect("invalid time format");
|
||||
|
||||
// Get time offset for local timezone from UTC
|
||||
// let time_offset =
|
||||
// time::UtcOffset::current_local_offset().unwrap_or(time::UtcOffset::UTC);
|
||||
// nerd fight: https://www.reddit.com/r/learnrust/comments/1bgc4p7/time_crate_never_manages_to_get_local_time/
|
||||
// Use chrono instead of time crate to get local offset
|
||||
let offset_in_sec = chrono::Local::now().offset().local_minus_utc();
|
||||
let time_offset =
|
||||
time::UtcOffset::from_whole_seconds(offset_in_sec).expect("invalid utc offset");
|
||||
let timer = fmt::time::OffsetTime::new(time_offset, timer);
|
||||
|
||||
let filter = veilid_core::VeilidLayerFilter::new(
|
||||
convert_loglevel(settingsr.logging.terminal.level),
|
||||
&settingsr.logging.terminal.ignore_log_targets,
|
||||
);
|
||||
let layer = fmt::Layer::new()
|
||||
.compact()
|
||||
.with_timer(timer)
|
||||
.with_ansi(true)
|
||||
.with_writer(std::io::stdout)
|
||||
.with_filter(filter.clone());
|
||||
filters.insert("terminal", filter);
|
||||
@@ -96,6 +111,7 @@ impl VeilidLogs {
|
||||
}
|
||||
|
||||
// Perfetto logger
|
||||
#[cfg(unix)]
|
||||
if settingsr.logging.perfetto.enabled {
|
||||
let filter = veilid_core::VeilidLayerFilter::new_no_default(
|
||||
veilid_core::VeilidConfigLogLevel::Trace,
|
||||
@@ -140,7 +156,7 @@ impl VeilidLogs {
|
||||
.tracing()
|
||||
.with_exporter(exporter)
|
||||
.with_trace_config(opentelemetry_sdk::trace::Config::default().with_resource(
|
||||
Resource::new(vec![KeyValue::new(
|
||||
Resource::new(vec![opentelemetry::KeyValue::new(
|
||||
opentelemetry_semantic_conventions::resource::SERVICE_NAME,
|
||||
format!(
|
||||
"veilid_server:{}",
|
||||
|
||||
Reference in New Issue
Block a user