hypha: add script for quick debugging and set log levels ot warn by default

This commit is contained in:
Alex Zenla 2024-02-01 10:28:17 +00:00
parent bd56de235f
commit e7cea3d7ed
No known key found for this signature in database
GPG Key ID: 067B238899B51269
4 changed files with 18 additions and 2 deletions

View File

@ -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 {

View File

@ -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" {

View File

@ -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"

13
scripts/hyphactl-debug.sh Executable file
View File

@ -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 "${@}"