Skip to content

Commit

Permalink
reduce module chattiness at boot
Browse files Browse the repository at this point in the history
  • Loading branch information
nick1udwig committed Dec 20, 2024
1 parent 5050ede commit 5f9c34c
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 54 deletions.
8 changes: 0 additions & 8 deletions kinode/src/http/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,6 @@ async fn serve(
send_to_loop: MessageSender,
print_tx: PrintSender,
) {
Printout::new(
0,
HTTP_SERVER_PROCESS_ID.clone(),
format!("http-server: running on port {our_port}"),
)
.send(&print_tx)
.await;

// filter to receive websockets
let cloned_our = our.clone();
let cloned_jwt_secret_bytes = jwt_secret_bytes.clone();
Expand Down
43 changes: 21 additions & 22 deletions kinode/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const CAP_CHANNEL_CAPACITY: usize = 1_000;
const KV_CHANNEL_CAPACITY: usize = 1_000;
const SQLITE_CHANNEL_CAPACITY: usize = 1_000;
const FD_MANAGER_CHANNEL_CAPACITY: usize = 1_000;
const VERSION: &str = env!("CARGO_PKG_VERSION");
const WS_MIN_PORT: u16 = 9_000;
const TCP_MIN_PORT: u16 = 10_000;
const MAX_PORT: u16 = 65_535;
Expand All @@ -66,17 +65,6 @@ pub const MULTICALL_ADDRESS: &str = "0xcA11bde05977b3631167028862bE2a173976CA11"

#[tokio::main]
async fn main() {
// embed values in binary for inspection without running & print on boot
// e.g., to inspect without running, use
// ```bash
// strings kinode | grep DOCKER_BUILD_IMAGE_VERSION
// ```
println!(
"\nDOCKER_BUILD_IMAGE_VERSION: {}\nPACKAGES_ZIP_HASH: {}\n",
env!("DOCKER_BUILD_IMAGE_VERSION"),
env!("PACKAGES_ZIP_HASH"),
);

let app = build_command();

let matches = app.get_matches();
Expand All @@ -87,8 +75,7 @@ async fn main() {
panic!("failed to create home directory: {e:?}");
}
let home_directory_path = std::fs::canonicalize(&home_directory_path)
.expect("specified home directory {home_directory_path} not found");
println!("home at {home_directory_path:?}\r");
.expect(&format!("specified home directory {home_directory_path} not found"));
let http_server_port = set_http_server_port(matches.get_one::<u16>("port")).await;
let ws_networking_port = matches.get_one::<u16>("ws-port");
#[cfg(not(feature = "simulation-mode"))]
Expand Down Expand Up @@ -126,7 +113,6 @@ async fn main() {
tokio::fs::read_to_string(home_directory_path.join(".eth_providers")).await
{
if let Ok(contents) = serde_json::from_str(&contents) {
println!("loaded saved eth providers\r");
contents
} else {
println!("error loading saved eth providers, using default providers\r");
Expand Down Expand Up @@ -233,8 +219,9 @@ async fn main() {

#[cfg(not(feature = "simulation-mode"))]
println!(
"login or register at http://localhost:{}\r",
http_server_port
"Welcome to Kinode.\nThe time is {}.\nLogin or register at http://localhost:{}\r",
chrono::Local::now().to_rfc3339(),
http_server_port,
);
#[cfg(not(feature = "simulation-mode"))]
let (our, encoded_keyfile, decoded_keyfile) = match password {
Expand Down Expand Up @@ -475,7 +462,7 @@ async fn main() {
}
quit = terminal::terminal(
our.clone(),
VERSION,
env!("CARGO_PKG_VERSION"),
home_directory_path.clone(),
kernel_message_sender.clone(),
kernel_debug_message_sender,
Expand All @@ -487,6 +474,7 @@ async fn main() {
max_log_size.copied(),
number_log_files.copied(),
process_verbosity,
&our_ip,
) => {
match quit {
Ok(()) => {
Expand Down Expand Up @@ -678,9 +666,22 @@ pub async fn simulate_node(
/// build the command line interface for kinode
///
fn build_command() -> Command {
// embed values in binary for inspection without running & print on boot
// e.g., to inspect without running, use
// ```bash
// strings kinode | grep DOCKER_BUILD_IMAGE_VERSION
// ```
let version = concat!(
env!("CARGO_PKG_VERSION"),
"\nDOCKER_BUILD_IMAGE_VERSION: ",
env!("DOCKER_BUILD_IMAGE_VERSION"),
"\nPACKAGES_ZIP_HASH: ",
env!("PACKAGES_ZIP_HASH"),
"\n",
);
let app = Command::new("kinode")
.version(VERSION)
.author("Kinode DAO: https://github.com/kinode-dao")
.version(version)
.author("Sybil Technologies AG")
.about("A General Purpose Sovereign Cloud Computing Platform")
.arg(arg!([home] "Path to home directory").required(true))
.arg(
Expand Down Expand Up @@ -763,10 +764,8 @@ async fn find_public_ip() -> std::net::Ipv4Addr {

#[cfg(not(feature = "simulation-mode"))]
{
println!("Finding public IP address...");
match tokio::time::timeout(std::time::Duration::from_secs(5), public_ip::addr_v4()).await {
Ok(Some(ip)) => {
println!("Public IP found: {ip}");
ip
}
_ => {
Expand Down
4 changes: 2 additions & 2 deletions kinode/src/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub async fn networking(
ip
));
}
utils::print_loud(&ext.print_tx, "going online as a direct node").await;
utils::print_debug(&ext.print_tx, "going online as a direct node").await;
if !ports.contains_key(WS_PROTOCOL) && !ports.contains_key(TCP_PROTOCOL) {
return Err(anyhow::anyhow!(
"net: fatal error: need at least one networking protocol"
Expand All @@ -108,7 +108,7 @@ pub async fn networking(
"net: fatal error: need at least one router, update your KNS identity"
));
}
utils::print_loud(&ext.print_tx, "going online as an indirect node").await;
utils::print_debug(&ext.print_tx, "going online as an indirect node").await;
// if we are indirect, we need to establish a route to each router
// and then listen for incoming connections on each of them.
// this task will periodically check and re-connect to routers
Expand Down
5 changes: 0 additions & 5 deletions kinode/src/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,6 @@ pub async fn connect_to_provider(maybe_rpc: Option<String>) -> RootProvider<PubS
} else {
"wss://optimism-rpc.publicnode.com".to_string()
};
println!(
"Connecting to Optimism RPC at {url}\n\
Specify a different RPC URL with the --rpc flag."
);

let client = match ProviderBuilder::new().on_ws(WsConnect::new(url)).await {
Ok(client) => client,
Expand All @@ -262,7 +258,6 @@ pub async fn connect_to_provider(maybe_rpc: Option<String>) -> RootProvider<PubS
}
};

println!("Connected to Optimism RPC");
client
}

Expand Down
1 change: 0 additions & 1 deletion kinode/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@ async fn bootstrap(
continue;
}

println!("fs: handling package {package_name}...\r");
let package_publisher = package_metadata.properties.publisher.as_str();

// create a new package in VFS
Expand Down
9 changes: 8 additions & 1 deletion kinode/src/terminal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,15 @@ pub async fn terminal(
max_log_size: Option<u64>,
number_log_files: Option<u64>,
process_verbosity: ProcessVerbosity,
our_ip: &std::net::Ipv4Addr,
) -> anyhow::Result<()> {
let (stdout, _maybe_raw_mode) = utils::splash(&our, version, is_detached)?;
let (stdout, _maybe_raw_mode) = utils::splash(
&our,
version,
is_detached,
our_ip,
&home_directory_path,
)?;

let (win_cols, win_rows) = crossterm::terminal::size().unwrap_or_else(|_| (0, 0));

Expand Down
31 changes: 16 additions & 15 deletions kinode/src/terminal/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ pub fn splash(
our: &Identity,
version: &str,
is_detached: bool,
our_ip: &std::net::Ipv4Addr,
home_directory_path: &Path,
) -> std::io::Result<(Stdout, Option<RawMode>)> {
let mut stdout = std::io::stdout();
crossterm::execute!(
Expand All @@ -50,9 +52,7 @@ pub fn splash(
stdout,
crossterm::style::SetForegroundColor(crossterm::style::Color::Magenta),
crossterm::style::Print(format!(
r#"
.`
`@@,, ,* 888 d8P d8b 888
r#" `@@,, ,* 888 d8P d8b 888
`@%@@@, ,~-##` 888 d8P Y8P 888
~@@#@%#@@, ##### 888 d8P 888
~-%######@@@, ##### 888d88K 888 88888b. .d88b. .d88888 .d88b.
Expand All @@ -65,21 +65,21 @@ pub fn splash(
/##%@# ` runtime version {}
./######` a general purpose sovereign cloud computer
/.^`.#^#^`
` ,#`#`#,
,/ /` `
` ,#`#`#, public IP {}
,/ /` ` home directory at {}
.*`
networking public key: {}
{}
"#,
networking public key: {}{}\n"#,
our.name,
if our.is_direct() {
"direct"
} else {
"indirect"
},
version,
our_ip,
home_directory_path.display(),
our.networking_key,
if is_detached { "(detached)" } else { "" }
if is_detached { "\n(detached)" } else { "" }
)),
crossterm::style::ResetColor
)
Expand All @@ -89,8 +89,7 @@ pub fn splash(
stdout,
crossterm::style::SetForegroundColor(crossterm::style::Color::Magenta),
crossterm::style::Print(format!(
r#"
888 d8P d8b 888
r#"888 d8P d8b 888
888 d8P Y8P 888
888 d8P 888
888d88K 888 88888b. .d88b. .d88888 .d88b.
Expand All @@ -102,18 +101,20 @@ pub fn splash(
{} ({})
version {}
a general purpose sovereign cloud computer
net pubkey: {}
{}
"#,
public IP {}
home directory at {}
net pubkey: {}{}\n"#,
our.name,
if our.is_direct() {
"direct"
} else {
"indirect"
},
version,
our_ip,
home_directory_path.display(),
our.networking_key,
if is_detached { "(detached)" } else { "" }
if is_detached { "\n(detached)" } else { "" }
)),
crossterm::style::ResetColor
)?;
Expand Down

0 comments on commit 5f9c34c

Please sign in to comment.