improved debuggability

This commit is contained in:
Aiden McClelland
2025-09-24 22:28:24 -06:00
parent ad5d3ad01d
commit 24521e3cac
14 changed files with 57 additions and 24 deletions

View File

@@ -30,8 +30,10 @@ ALL_TARGETS := $(STARTD_SRC) $(ENVIRONMENT_FILE) $(GIT_HASH_FILE) $(VERSION_FILE
echo cargo-deps/aarch64-unknown-linux-musl/release/pi-beep; \ echo cargo-deps/aarch64-unknown-linux-musl/release/pi-beep; \
fi) \ fi) \
$(shell /bin/bash -c 'if [[ "${ENVIRONMENT}" =~ (^|-)unstable($$|-) ]]; then \ $(shell /bin/bash -c 'if [[ "${ENVIRONMENT}" =~ (^|-)unstable($$|-) ]]; then \
echo cargo-deps/$(ARCH)-unknown-linux-musl/release/tokio-console; \
echo cargo-deps/$(ARCH)-unknown-linux-musl/release/flamegraph; \ echo cargo-deps/$(ARCH)-unknown-linux-musl/release/flamegraph; \
fi') \
$(shell /bin/bash -c 'if [[ "${ENVIRONMENT}" =~ (^|-)console($$|-) ]]; then \
echo cargo-deps/$(ARCH)-unknown-linux-musl/release/tokio-console; \
fi') fi')
REBUILD_TYPES = 1 REBUILD_TYPES = 1
@@ -139,9 +141,11 @@ install: $(ALL_TARGETS)
$(call ln,/usr/bin/startbox,$(DESTDIR)/usr/bin/start-cli) $(call ln,/usr/bin/startbox,$(DESTDIR)/usr/bin/start-cli)
if [ "$(PLATFORM)" = "raspberrypi" ]; then $(call cp,cargo-deps/aarch64-unknown-linux-musl/release/pi-beep,$(DESTDIR)/usr/bin/pi-beep); fi if [ "$(PLATFORM)" = "raspberrypi" ]; then $(call cp,cargo-deps/aarch64-unknown-linux-musl/release/pi-beep,$(DESTDIR)/usr/bin/pi-beep); fi
if /bin/bash -c '[[ "${ENVIRONMENT}" =~ (^|-)unstable($$|-) ]]'; then \ if /bin/bash -c '[[ "${ENVIRONMENT}" =~ (^|-)unstable($$|-) ]]'; then \
$(call cp,cargo-deps/$(ARCH)-unknown-linux-musl/release/tokio-console,$(DESTDIR)/usr/bin/tokio-console); \
$(call cp,cargo-deps/$(ARCH)-unknown-linux-musl/release/flamegraph,$(DESTDIR)/usr/bin/flamegraph); \ $(call cp,cargo-deps/$(ARCH)-unknown-linux-musl/release/flamegraph,$(DESTDIR)/usr/bin/flamegraph); \
fi fi
if /bin/bash -c '[[ "${ENVIRONMENT}" =~ (^|-)console($$|-) ]]'; then \
$(call cp,cargo-deps/$(ARCH)-unknown-linux-musl/release/tokio-console,$(DESTDIR)/usr/bin/tokio-console); \
fi
$(call cp,cargo-deps/$(ARCH)-unknown-linux-musl/release/startos-backup-fs,$(DESTDIR)/usr/bin/startos-backup-fs) $(call cp,cargo-deps/$(ARCH)-unknown-linux-musl/release/startos-backup-fs,$(DESTDIR)/usr/bin/startos-backup-fs)
$(call ln,/usr/bin/startos-backup-fs,$(DESTDIR)/usr/sbin/mount.backup-fs) $(call ln,/usr/bin/startos-backup-fs,$(DESTDIR)/usr/sbin/mount.backup-fs)

25
core/Cargo.lock generated
View File

@@ -881,6 +881,17 @@ dependencies = [
"windows-targets 0.52.6", "windows-targets 0.52.6",
] ]
[[package]]
name = "backtrace-on-stack-overflow"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fd2d70527f3737a1ad17355e260706c1badebabd1fa06a7a053407380df841b"
dependencies = [
"backtrace",
"libc",
"nix 0.23.2",
]
[[package]] [[package]]
name = "barrage" name = "barrage"
version = "0.2.3" version = "0.2.3"
@@ -4679,6 +4690,19 @@ dependencies = [
"smallvec", "smallvec",
] ]
[[package]]
name = "nix"
version = "0.23.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c"
dependencies = [
"bitflags 1.3.2",
"cc",
"cfg-if",
"libc",
"memoffset 0.6.5",
]
[[package]] [[package]]
name = "nix" name = "nix"
version = "0.24.3" version = "0.24.3"
@@ -7276,6 +7300,7 @@ dependencies = [
"async-trait", "async-trait",
"axum 0.8.4", "axum 0.8.4",
"backhand", "backhand",
"backtrace-on-stack-overflow",
"barrage", "barrage",
"base32", "base32",
"base64 0.22.1", "base64 0.22.1",

View File

@@ -46,7 +46,7 @@ if [ -n "$FEATURES" ]; then
fi fi
RUSTFLAGS="" RUSTFLAGS=""
if [[ "${ENVIRONMENT:-}" =~ (^|-)unstable($|-) ]]; then if [[ "${ENVIRONMENT:-}" =~ (^|-)console($|-) ]]; then
RUSTFLAGS="--cfg tokio_unstable" RUSTFLAGS="--cfg tokio_unstable"
fi fi

View File

@@ -22,7 +22,7 @@ cd ..
FEATURES="$(echo $ENVIRONMENT | sed 's/-/,/g')" FEATURES="$(echo $ENVIRONMENT | sed 's/-/,/g')"
RUSTFLAGS="" RUSTFLAGS=""
if [[ "${ENVIRONMENT}" =~ (^|-)unstable($|-) ]]; then if [[ "${ENVIRONMENT}" =~ (^|-)console($|-) ]]; then
RUSTFLAGS="--cfg tokio_unstable" RUSTFLAGS="--cfg tokio_unstable"
fi fi

View File

@@ -22,7 +22,7 @@ cd ..
FEATURES="$(echo $ENVIRONMENT | sed 's/-/,/g')" FEATURES="$(echo $ENVIRONMENT | sed 's/-/,/g')"
RUSTFLAGS="" RUSTFLAGS=""
if [[ "${ENVIRONMENT}" =~ (^|-)unstable($|-) ]]; then if [[ "${ENVIRONMENT}" =~ (^|-)console($|-) ]]; then
RUSTFLAGS="--cfg tokio_unstable" RUSTFLAGS="--cfg tokio_unstable"
fi fi

View File

@@ -27,7 +27,7 @@ cd ..
FEATURES="$(echo $ENVIRONMENT | sed 's/-/,/g')" FEATURES="$(echo $ENVIRONMENT | sed 's/-/,/g')"
RUSTFLAGS="" RUSTFLAGS=""
if [[ "${ENVIRONMENT}" =~ (^|-)unstable($|-) ]]; then if [[ "${ENVIRONMENT}" =~ (^|-)console($|-) ]]; then
RUSTFLAGS="--cfg tokio_unstable" RUSTFLAGS="--cfg tokio_unstable"
fi fi

View File

@@ -22,7 +22,7 @@ cd ..
FEATURES="$(echo $ENVIRONMENT | sed 's/-/,/g')" FEATURES="$(echo $ENVIRONMENT | sed 's/-/,/g')"
RUSTFLAGS="" RUSTFLAGS=""
if [[ "${ENVIRONMENT}" =~ (^|-)unstable($|-) ]]; then if [[ "${ENVIRONMENT}" =~ (^|-)console($|-) ]]; then
RUSTFLAGS="--cfg tokio_unstable" RUSTFLAGS="--cfg tokio_unstable"
fi fi

View File

@@ -22,7 +22,7 @@ cd ..
FEATURES="$(echo $ENVIRONMENT | sed 's/-/,/g')" FEATURES="$(echo $ENVIRONMENT | sed 's/-/,/g')"
RUSTFLAGS="" RUSTFLAGS=""
if [[ "${ENVIRONMENT}" =~ (^|-)unstable($|-) ]]; then if [[ "${ENVIRONMENT}" =~ (^|-)console($|-) ]]; then
RUSTFLAGS="--cfg tokio_unstable" RUSTFLAGS="--cfg tokio_unstable"
fi fi

View File

@@ -22,7 +22,7 @@ cd ..
FEATURES="$(echo $ENVIRONMENT | sed 's/-/,/g')" FEATURES="$(echo $ENVIRONMENT | sed 's/-/,/g')"
RUSTFLAGS="" RUSTFLAGS=""
if [[ "${ENVIRONMENT}" =~ (^|-)unstable($|-) ]]; then if [[ "${ENVIRONMENT}" =~ (^|-)console($|-) ]]; then
RUSTFLAGS="--cfg tokio_unstable" RUSTFLAGS="--cfg tokio_unstable"
fi fi

View File

@@ -48,13 +48,14 @@ cli-registry = []
cli-startd = [] cli-startd = []
cli-tunnel = [] cli-tunnel = []
default = ["cli", "startd", "registry", "cli-container", "tunnel"] default = ["cli", "startd", "registry", "cli-container", "tunnel"]
dev = [] dev = ["backtrace-on-stack-overflow"]
docker = [] docker = []
registry = [] registry = []
startd = ["mail-send"] startd = ["mail-send"]
test = [] test = []
tunnel = [] tunnel = []
unstable = ["console-subscriber", "tokio/tracing"] console = ["console-subscriber", "tokio/tracing"]
unstable = ["backtrace-on-stack-overflow"]
[dependencies] [dependencies]
arti-client = { version = "0.33", features = [ arti-client = { version = "0.33", features = [
@@ -82,6 +83,7 @@ async-trait = "0.1.74"
axum = { version = "0.8.4", features = ["ws"] } axum = { version = "0.8.4", features = ["ws"] }
barrage = "0.2.3" barrage = "0.2.3"
backhand = "0.21.0" backhand = "0.21.0"
backtrace-on-stack-overflow = { version = "0.3.0", optional = true }
base32 = "0.5.0" base32 = "0.5.0"
base64 = "0.22.1" base64 = "0.22.1"
base64ct = "1.6.0" base64ct = "1.6.0"

View File

@@ -78,7 +78,7 @@ pub struct RpcContextSeed {
} }
impl Drop for RpcContextSeed { impl Drop for RpcContextSeed {
fn drop(&mut self) { fn drop(&mut self) {
tracing::error!("RpcContext is dropped"); tracing::info!("RpcContext is dropped");
} }
} }

View File

@@ -1,3 +1,7 @@
fn main() { fn main() {
#[cfg(feature = "backtrace-on-stack-overflow")]
unsafe {
backtrace_on_stack_overflow::enable()
};
startos::bins::startbox() startos::bins::startbox()
} }

View File

@@ -2,7 +2,7 @@ use std::net::Ipv4Addr;
use clap::Parser; use clap::Parser;
use ipnet::Ipv4Net; use ipnet::Ipv4Net;
use rpc_toolkit::{Context, Empty, HandlerExt, ParentHandler, from_fn_async}; use rpc_toolkit::{from_fn_async, Context, Empty, HandlerExt, ParentHandler};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::context::CliContext; use crate::context::CliContext;
@@ -22,7 +22,7 @@ pub fn tunnel_api<C: Context>() -> ParentHandler<C> {
subnet_api::<C>().with_about("Add, remove, or modify subnets"), subnet_api::<C>().with_about("Add, remove, or modify subnets"),
) )
// .subcommand( // .subcommand(
// "forward", // "port-forward",
// ParentHandler::<C>::new() // ParentHandler::<C>::new()
// .subcommand( // .subcommand(
// "add", // "add",
@@ -77,19 +77,19 @@ pub fn subnet_api<C: Context>() -> ParentHandler<C, SubnetParams> {
// .with_call_remote::<CliContext>(), // .with_call_remote::<CliContext>(),
// ) // )
// .subcommand( // .subcommand(
// "add-client", // "add-device",
// from_fn_async(add_client) // from_fn_async(add_device)
// .with_metadata("sync_db", Value::Bool(true)) // .with_metadata("sync_db", Value::Bool(true))
// .no_display() // .no_display()
// .with_about("Add a client to a subnet") // .with_about("Add a device to a subnet")
// .with_call_remote::<CliContext>(), // .with_call_remote::<CliContext>(),
// ) // )
// .subcommand( // .subcommand(
// "remove-client", // "remove-device",
// from_fn_async(remove_client) // from_fn_async(remove_device)
// .with_metadata("sync_db", Value::Bool(true)) // .with_metadata("sync_db", Value::Bool(true))
// .no_display() // .no_display()
// .with_about("Remove a client from a subnet") // .with_about("Remove a device from a subnet")
// .with_call_remote::<CliContext>(), // .with_call_remote::<CliContext>(),
// ) // )
} }

View File

@@ -59,7 +59,7 @@ impl StartOSLogger {
fn base_subscriber(logfile: LogFile) -> impl Subscriber { fn base_subscriber(logfile: LogFile) -> impl Subscriber {
use tracing_error::ErrorLayer; use tracing_error::ErrorLayer;
use tracing_subscriber::prelude::*; use tracing_subscriber::prelude::*;
use tracing_subscriber::{EnvFilter, fmt}; use tracing_subscriber::{fmt, EnvFilter};
let filter_layer = || { let filter_layer = || {
EnvFilter::builder() EnvFilter::builder()
@@ -80,10 +80,8 @@ impl StartOSLogger {
let sub = tracing_subscriber::registry(); let sub = tracing_subscriber::registry();
#[cfg(feature = "unstable")] #[cfg(feature = "console-subscriber")]
let sub = sub.with(console_subscriber::spawn()); let sub = sub.with(console_subscriber::spawn());
#[cfg(not(feature = "unstable"))]
let sub = sub.with(filter_layer());
let sub = sub.with(fmt_layer).with(ErrorLayer::default()); let sub = sub.with(fmt_layer).with(ErrorLayer::default());