From 046eff44ec24e0299cd5ea1e869811044c3df952 Mon Sep 17 00:00:00 2001 From: Nitish Tiwari Date: Tue, 3 Jan 2023 16:11:23 +0530 Subject: [PATCH 1/4] Cleanup the banner --- server/src/banner.rs | 76 +++++++++++++++++++++----------------------- server/src/utils.rs | 2 +- 2 files changed, 37 insertions(+), 41 deletions(-) diff --git a/server/src/banner.rs b/server/src/banner.rs index 2091c44bb..672cadc21 100644 --- a/server/src/banner.rs +++ b/server/src/banner.rs @@ -20,34 +20,41 @@ use crossterm::style::Stylize; use crate::{option::Config, storage::StorageMetadata}; +use crate::utils::{uid::Uid}; pub fn print(config: &Config, meta: StorageMetadata) { let scheme = config.parseable.get_scheme(); - status_info(config, &scheme); + status_info(config, &scheme, meta.deployment_id); storage_info(config); - version::print(meta.deployment_id); + about::print(); println!(); } -fn status_info(config: &Config, scheme: &str) { +fn status_info(config: &Config, scheme: &str, id: Uid) { let url = format!("{}://{}", scheme, config.parseable.address).underlined(); - eprintln!( - " - {} - {} - {}", - format!("Parseable server started at: {}", url).bold(), - format!("Username: {}", config.parseable.username).bold(), - format!("Password: {}", config.parseable.password).bold(), - ); - if config.is_default_creds() { - warning_line(); eprintln!( " - {}", - "Using default credentials for Parseable server".red() - ) + {} + Running at: \"{}\" + Credentials: {} + Deployment UID: \"{}\"", + "Parseable Server".to_string().bold(), + url, + "\"Using default creds admin, admin. Please set credentials with P_USERNAME and P_PASSWORD.\"".to_string().red(), + id.to_string() + ); + } else { + eprintln!( + " + {} + Running at: \"{}\" + Credentials: \"As set in P_USERNAME and P_PASSWORD environment variables\" + Deployment UID: \"{}\"", + "Parseable Server".to_string().bold(), + url, + id.to_string(), + ); } } @@ -55,31 +62,23 @@ fn storage_info(config: &Config) { eprintln!( " {} - Mode: {} - Staging path: {} - Store path: {}", - "Storage:".to_string().blue().bold(), + Mode: \"{}\" + Staging: \"{}\" + Store: \"{}\"", + "Storage:".to_string().cyan().bold(), config.storage_name, config.staging_dir().to_string_lossy(), config.storage().get_endpoint(), ) } -pub fn warning_line() { - eprint!( - " - {}", - "Warning:".to_string().red().bold(), - ); -} - -pub mod version { +pub mod about { use chrono::Duration; use chrono_humanize::{Accuracy, Tense}; use crossterm::style::Stylize; use std::fmt; - use crate::utils::{uid::Uid, update}; + use crate::utils::update; pub enum ParseableVersion { Version(semver::Version), @@ -95,29 +94,26 @@ pub mod version { } } - pub fn print_version(current_version: semver::Version, commit_hash: String, id: Uid) { + pub fn print_version(current_version: semver::Version, commit_hash: String) { eprint!( " {} - Deployment ID: {} - Version: {} - Commit hash: {} - GitHub: https://github.com/parseablehq/parseable - Docs: https://www.parseable.io/docs/introduction", + Version: \"{}\" + Commit: \"{}\" + Docs: \"https://www.parseable.io/docs/introduction\"", "About:".to_string().blue().bold(), - id.to_string(), current_version, commit_hash ); } - pub fn print(id: Uid) { + pub fn print() { // print current version let current = current(); match current.0 { ParseableVersion::Version(current_version) => { - print_version(current_version.clone(), current.1, id); + print_version(current_version.clone(), current.1); // check for latest release, if it cannot be fetched then print error as warn and return let latest_release = match update::get_latest() { Ok(latest_release) => latest_release, diff --git a/server/src/utils.rs b/server/src/utils.rs index 0972107f3..97b800a73 100644 --- a/server/src/utils.rs +++ b/server/src/utils.rs @@ -133,7 +133,7 @@ pub mod uid { } pub mod update { - use crate::banner::version::current; + use crate::banner::about::current; use std::{path::Path, time::Duration}; use anyhow::anyhow; From ba47830a903866da0291f6899cdd1a14e4e03973 Mon Sep 17 00:00:00 2001 From: Nitish Tiwari Date: Tue, 3 Jan 2023 16:17:18 +0530 Subject: [PATCH 2/4] Fix mode and rustfmt --- server/src/banner.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/server/src/banner.rs b/server/src/banner.rs index 672cadc21..4531bb1c6 100644 --- a/server/src/banner.rs +++ b/server/src/banner.rs @@ -19,8 +19,8 @@ use crossterm::style::Stylize; +use crate::utils::uid::Uid; use crate::{option::Config, storage::StorageMetadata}; -use crate::utils::{uid::Uid}; pub fn print(config: &Config, meta: StorageMetadata) { let scheme = config.parseable.get_scheme(); @@ -43,7 +43,7 @@ fn status_info(config: &Config, scheme: &str, id: Uid) { url, "\"Using default creds admin, admin. Please set credentials with P_USERNAME and P_PASSWORD.\"".to_string().red(), id.to_string() - ); + ); } else { eprintln!( " @@ -51,14 +51,18 @@ fn status_info(config: &Config, scheme: &str, id: Uid) { Running at: \"{}\" Credentials: \"As set in P_USERNAME and P_PASSWORD environment variables\" Deployment UID: \"{}\"", - "Parseable Server".to_string().bold(), - url, - id.to_string(), - ); + "Parseable Server".to_string().bold(), + url, + id.to_string(), + ); } } fn storage_info(config: &Config) { + let mut mode = "S3 bucket"; + if config.storage_name == "drive" { + mode = "Local drive"; + } eprintln!( " {} @@ -66,7 +70,7 @@ fn storage_info(config: &Config) { Staging: \"{}\" Store: \"{}\"", "Storage:".to_string().cyan().bold(), - config.storage_name, + mode, config.staging_dir().to_string_lossy(), config.storage().get_endpoint(), ) From 810fa95152677c36e097563905cfe44f038f1d55 Mon Sep 17 00:00:00 2001 From: Nitish Tiwari Date: Tue, 3 Jan 2023 17:24:47 +0530 Subject: [PATCH 3/4] More fixes --- server/src/banner.rs | 33 ++++++++++++++------------------- server/src/option.rs | 2 +- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/server/src/banner.rs b/server/src/banner.rs index 4531bb1c6..31e23abc3 100644 --- a/server/src/banner.rs +++ b/server/src/banner.rs @@ -31,31 +31,26 @@ pub fn print(config: &Config, meta: StorageMetadata) { } fn status_info(config: &Config, scheme: &str, id: Uid) { - let url = format!("{}://{}", scheme, config.parseable.address).underlined(); + let url = format!("\"{}://{}\"", scheme, config.parseable.address) + .underlined(); + let mut credentials = + String::from("\"As set in P_USERNAME and P_PASSWORD environment variables\""); + if config.is_default_creds() { - eprintln!( - " + credentials = "\"Using default creds admin, admin. Please set credentials with P_USERNAME and P_PASSWORD.\"".red().to_string(); + } + + eprintln!( + " {} - Running at: \"{}\" + Running at: {} Credentials: {} Deployment UID: \"{}\"", "Parseable Server".to_string().bold(), url, - "\"Using default creds admin, admin. Please set credentials with P_USERNAME and P_PASSWORD.\"".to_string().red(), - id.to_string() + credentials, + id.to_string(), ); - } else { - eprintln!( - " - {} - Running at: \"{}\" - Credentials: \"As set in P_USERNAME and P_PASSWORD environment variables\" - Deployment UID: \"{}\"", - "Parseable Server".to_string().bold(), - url, - id.to_string(), - ); - } } fn storage_info(config: &Config) { @@ -105,7 +100,7 @@ pub mod about { Version: \"{}\" Commit: \"{}\" Docs: \"https://www.parseable.io/docs/introduction\"", - "About:".to_string().blue().bold(), + "About:".to_string().bold(), current_version, commit_hash ); diff --git a/server/src/option.rs b/server/src/option.rs index f82210ea7..c9e03bb0b 100644 --- a/server/src/option.rs +++ b/server/src/option.rs @@ -271,7 +271,7 @@ impl Server { .long(Self::ADDRESS) .env("P_ADDR") .value_name("ADDR:PORT") - .default_value("0.0.0.0:8000") + .default_value("127.0.0.1:8000") .value_parser(validation::socket_addr) .help("The address on which the http server will listen."), ) From 915f92f007bb6021037cc8b98a34cbb4358953d6 Mon Sep 17 00:00:00 2001 From: Nitish Tiwari Date: Tue, 3 Jan 2023 17:27:09 +0530 Subject: [PATCH 4/4] Fix fmt --- server/src/banner.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server/src/banner.rs b/server/src/banner.rs index 31e23abc3..fd74d297e 100644 --- a/server/src/banner.rs +++ b/server/src/banner.rs @@ -31,8 +31,7 @@ pub fn print(config: &Config, meta: StorageMetadata) { } fn status_info(config: &Config, scheme: &str, id: Uid) { - let url = format!("\"{}://{}\"", scheme, config.parseable.address) - .underlined(); + let url = format!("\"{}://{}\"", scheme, config.parseable.address).underlined(); let mut credentials = String::from("\"As set in P_USERNAME and P_PASSWORD environment variables\"");