From e7cea3d7ed73de792c6b32e6d05fb354a7748cbd Mon Sep 17 00:00:00 2001 From: Alex Zenla Date: Thu, 1 Feb 2024 10:28:17 +0000 Subject: [PATCH] hypha: add script for quick debugging and set log levels ot warn by default --- hypha/bin/container.rs | 2 ++ hypha/bin/controller.rs | 3 ++- initrd/build.sh | 2 +- scripts/hyphactl-debug.sh | 13 +++++++++++++ 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100755 scripts/hyphactl-debug.sh diff --git a/hypha/bin/container.rs b/hypha/bin/container.rs index 6fa5a1d..595445c 100644 --- a/hypha/bin/container.rs +++ b/hypha/bin/container.rs @@ -1,9 +1,11 @@ +use env_logger::Env; use anyhow::{anyhow, Result}; use hypha::container::init::ContainerInit; use std::env; fn main() -> Result<()> { env::set_var("RUST_BACKTRACE", "1"); + env_logger::Builder::from_env(Env::default().default_filter_or("warn")).init(); if env::var("HYPHA_UNSAFE_ALWAYS_ALLOW_INIT").unwrap_or("0".to_string()) != "1" { let pid = std::process::id(); if pid > 3 { diff --git a/hypha/bin/controller.rs b/hypha/bin/controller.rs index 8d7a530..9d0bf87 100644 --- a/hypha/bin/controller.rs +++ b/hypha/bin/controller.rs @@ -1,3 +1,4 @@ +use env_logger::Env; use anyhow::{anyhow, Result}; use clap::{Parser, Subcommand}; use hypha::ctl::Controller; @@ -46,7 +47,7 @@ enum Commands { } fn main() -> Result<()> { - env_logger::init(); + env_logger::Builder::from_env(Env::default().default_filter_or("warn")).init(); let args = ControllerArgs::parse(); let store_path = if args.store == "auto" { diff --git a/initrd/build.sh b/initrd/build.sh index 5282aa6..37cbf6d 100755 --- a/initrd/build.sh +++ b/initrd/build.sh @@ -4,7 +4,7 @@ set -e export RUSTFLAGS="-Ctarget-feature=+crt-static" cd "$(dirname "${0}")/.." HYPHA_DIR="${PWD}" -cargo build --release --target x86_64-unknown-linux-gnu +cargo build --bin hyphactr --release --target x86_64-unknown-linux-gnu INITRD_DIR="$(mktemp -d /tmp/hypha-initrd.XXXXXXXXXXXXX)" cp target/x86_64-unknown-linux-gnu/release/hyphactr "${INITRD_DIR}/init" chmod +x "${INITRD_DIR}/init" diff --git a/scripts/hyphactl-debug.sh b/scripts/hyphactl-debug.sh new file mode 100755 index 0000000..ce6d9f6 --- /dev/null +++ b/scripts/hyphactl-debug.sh @@ -0,0 +1,13 @@ +#!/bin/sh +set -e + +if [ -z "${RUST_LOG}" ] +then + RUST_LOG="INFO" +fi + +cd "$(dirname "${0}")/.." +./initrd/build.sh +sudo cp "target/initrd/initrd" "/var/lib/hypha/default/initrd" +cargo build --target x86_64-unknown-linux-gnu --bin hyphactl +exec sudo RUST_LOG="${RUST_LOG}" target/x86_64-unknown-linux-gnu/debug/hyphactl "${@}"