Browse Source

Gate pprof dependency behind cfg(unix) to fix Windows build

The pprof crate uses Unix-only APIs (nix, libc::pthread_t,
libc::siginfo_t, etc.) that don't exist on Windows. Move it to
[target.'cfg(unix)'.dependencies] and gate all profiling/debug
module usage with #[cfg(unix)].
dependabot/go_modules/seaweedfs-rdma-sidecar/golang.org/x/image-0.38.0
Chris Lu 2 days ago
parent
commit
e29b685c20
  1. 6
      seaweed-volume/Cargo.toml
  2. 17
      seaweed-volume/src/main.rs
  3. 2
      seaweed-volume/src/server/mod.rs

6
seaweed-volume/Cargo.toml

@ -65,8 +65,6 @@ reed-solomon-erasure = "6"
# Logging # Logging
tracing = "0.1" tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] } tracing-subscriber = { version = "0.3", features = ["env-filter"] }
pprof = { version = "0.15", features = ["prost-codec"] }
# Config # Config
toml = "0.8" toml = "0.8"
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
@ -127,6 +125,10 @@ aws-sdk-s3 = { version = "1.125.0", default-features = false, features = ["sigv4
aws-credential-types = "1" aws-credential-types = "1"
aws-types = "1" aws-types = "1"
# pprof is Unix-only (requires libc/nix APIs not available on Windows)
[target.'cfg(unix)'.dependencies]
pprof = { version = "0.15", features = ["prost-codec"] }
[dev-dependencies] [dev-dependencies]
tempfile = "3" tempfile = "3"

17
seaweed-volume/src/main.rs

@ -10,9 +10,11 @@ use seaweed_volume::security::tls::{
GrpcClientAuthPolicy, TlsPolicy, GrpcClientAuthPolicy, TlsPolicy,
}; };
use seaweed_volume::security::{Guard, SigningKey}; use seaweed_volume::security::{Guard, SigningKey};
#[cfg(unix)]
use seaweed_volume::server::debug::build_debug_router; use seaweed_volume::server::debug::build_debug_router;
use seaweed_volume::server::grpc_client::load_outgoing_grpc_tls; use seaweed_volume::server::grpc_client::load_outgoing_grpc_tls;
use seaweed_volume::server::grpc_server::VolumeGrpcService; use seaweed_volume::server::grpc_server::VolumeGrpcService;
#[cfg(unix)]
use seaweed_volume::server::profiling::CpuProfileSession; use seaweed_volume::server::profiling::CpuProfileSession;
use seaweed_volume::server::request_id::GrpcRequestIdLayer; use seaweed_volume::server::request_id::GrpcRequestIdLayer;
use seaweed_volume::server::volume_server::{ use seaweed_volume::server::volume_server::{
@ -24,6 +26,11 @@ use seaweed_volume::storage::types::DiskType;
use tokio_rustls::TlsAcceptor; use tokio_rustls::TlsAcceptor;
#[cfg(unix)]
type CpuProfileParam = Option<CpuProfileSession>;
#[cfg(not(unix))]
type CpuProfileParam = Option<()>;
const GRPC_MAX_MESSAGE_SIZE: usize = 1 << 30; const GRPC_MAX_MESSAGE_SIZE: usize = 1 << 30;
const GRPC_KEEPALIVE_INTERVAL: std::time::Duration = std::time::Duration::from_secs(60); const GRPC_KEEPALIVE_INTERVAL: std::time::Duration = std::time::Duration::from_secs(60);
const GRPC_KEEPALIVE_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(20); const GRPC_KEEPALIVE_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(20);
@ -42,6 +49,7 @@ fn main() {
let config = config::parse_cli(); let config = config::parse_cli();
seaweed_volume::server::server_stats::init_process_start(); seaweed_volume::server::server_stats::init_process_start();
#[cfg(unix)]
let cpu_profile = match CpuProfileSession::start(&config) { let cpu_profile = match CpuProfileSession::start(&config) {
Ok(session) => session, Ok(session) => session,
Err(e) => { Err(e) => {
@ -49,6 +57,8 @@ fn main() {
std::process::exit(1); std::process::exit(1);
} }
}; };
#[cfg(not(unix))]
let cpu_profile: Option<()> = None;
info!( info!(
"SeaweedFS Volume Server (Rust) v{}", "SeaweedFS Volume Server (Rust) v{}",
seaweed_volume::version::full_version() seaweed_volume::version::full_version()
@ -257,7 +267,7 @@ where
async fn run( async fn run(
config: VolumeServerConfig, config: VolumeServerConfig,
cpu_profile: Option<CpuProfileSession>,
#[allow(unused_variables)] cpu_profile: CpuProfileParam,
) -> Result<(), Box<dyn std::error::Error>> { ) -> Result<(), Box<dyn std::error::Error>> {
// Initialize the store // Initialize the store
let mut store = Store::new(config.index_type); let mut store = Store::new(config.index_type);
@ -435,6 +445,7 @@ async fn run(
state.clone(), state.clone(),
config.ui_enabled, config.ui_enabled,
); );
#[cfg(unix)]
if config.pprof { if config.pprof {
admin_router = admin_router.merge(build_debug_router()); admin_router = admin_router.merge(build_debug_router());
} }
@ -721,6 +732,7 @@ async fn run(
None None
}; };
#[cfg(unix)]
let debug_handle = if config.debug { let debug_handle = if config.debug {
let debug_addr = format!("0.0.0.0:{}", config.debug_port); let debug_addr = format!("0.0.0.0:{}", config.debug_port);
info!("Debug pprof server listening on {}", debug_addr); info!("Debug pprof server listening on {}", debug_addr);
@ -742,6 +754,8 @@ async fn run(
} else { } else {
None None
}; };
#[cfg(not(unix))]
let debug_handle: Option<tokio::task::JoinHandle<()>> = None;
let metrics_push_handle = { let metrics_push_handle = {
let push_state = state.clone(); let push_state = state.clone();
@ -774,6 +788,7 @@ async fn run(
// Close all volumes (flush and release file handles) matching Go's Shutdown() // Close all volumes (flush and release file handles) matching Go's Shutdown()
state.store.write().unwrap().close(); state.store.write().unwrap().close();
#[cfg(unix)]
if let Some(cpu_profile) = cpu_profile { if let Some(cpu_profile) = cpu_profile {
cpu_profile.finish().map_err(std::io::Error::other)?; cpu_profile.finish().map_err(std::io::Error::other)?;
} }

2
seaweed-volume/src/server/mod.rs

@ -1,9 +1,11 @@
#[cfg(unix)]
pub mod debug; pub mod debug;
pub mod grpc_client; pub mod grpc_client;
pub mod grpc_server; pub mod grpc_server;
pub mod handlers; pub mod handlers;
pub mod heartbeat; pub mod heartbeat;
pub mod memory_status; pub mod memory_status;
#[cfg(unix)]
pub mod profiling; pub mod profiling;
pub mod request_id; pub mod request_id;
pub mod server_stats; pub mod server_stats;

Loading…
Cancel
Save