From 8b0f2f50f0f0b59d9aa3511ef8339ae1e6807065 Mon Sep 17 00:00:00 2001 From: neon_arch Date: Thu, 3 Aug 2023 23:09:08 +0300 Subject: [PATCH 01/13] =?UTF-8?q?=F0=9F=94=A7=20chore:=20improve=20logging?= =?UTF-8?q?=20based=20on=20levels=20&=20config=20options=20(#173)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/parser.rs | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/config/parser.rs b/src/config/parser.rs index 51a83ea..33421b0 100644 --- a/src/config/parser.rs +++ b/src/config/parser.rs @@ -4,7 +4,7 @@ use super::parser_models::Style; use log::LevelFilter; use rlua::Lua; -use std::{collections::HashMap, format, fs, io::Write, path::Path, thread::available_parallelism}; +use std::{collections::HashMap, format, fs, path::Path, thread::available_parallelism}; // ------- Constants -------- static COMMON_DIRECTORY_NAME: &str = "websurfx"; @@ -79,26 +79,26 @@ impl Config { // Check whether logging has not been initialized before. if logging_initialized { - // Initializing logging middleware with level set to default or info. - let mut log_level: LevelFilter = LevelFilter::Off; - if logging && debug == false { - log_level = LevelFilter::Info; - } else if debug { - log_level = LevelFilter::Trace; - }; - env_logger::Builder::new().filter(None, log_level).init(); + if let Ok(pkg_env_var) = std::env::var("PKG_ENV"){ + if pkg_env_var.to_lowercase() == "dev" { + env_logger::Builder::new().filter(None, LevelFilter::Trace).init(); + } + } else { + // Initializing logging middleware with level set to default or info. + let mut log_level: LevelFilter = LevelFilter::Error; + if logging && debug == false { + log_level = LevelFilter::Info; + } else if debug { + log_level = LevelFilter::Debug; + }; + env_logger::Builder::new().filter(None, log_level).init(); + } } let threads: u8 = if parsed_threads == 0 { - let total_num_of_threads:usize = available_parallelism()?.get() /2; - if debug || logging { - log::error!("Config Error: The value of `threads` option should be a non zero positive integer"); - log::info!("Falling back to using {} threads", total_num_of_threads) - } else { - std::io::stdout() - .lock() - .write_all(&format!("Config Error: The value of `threads` option should be a non zero positive integer\nFalling back to using {} threads\n", total_num_of_threads).into_bytes())?; - }; + let total_num_of_threads: usize = available_parallelism()?.get() / 2; + log::error!("Config Error: The value of `threads` option should be a non zero positive integer"); + log::info!("Falling back to using {} threads", total_num_of_threads); total_num_of_threads as u8 } else { parsed_threads From 246d043e4a168845b96d7acd9a95236eca1a486e Mon Sep 17 00:00:00 2001 From: neon_arch Date: Thu, 3 Aug 2023 23:11:49 +0300 Subject: [PATCH 02/13] =?UTF-8?q?=F0=9F=9A=80=20chore:=20bump=20the=20app?= =?UTF-8?q?=20version=20(#173)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 14 +++++++------- Cargo.toml | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 98a6247..3138dfc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -190,7 +190,7 @@ dependencies = [ "serde_urlencoded 0.7.1", "smallvec 1.11.0", "socket2", - "time 0.3.24", + "time 0.3.25", "url 2.4.0", ] @@ -583,7 +583,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e859cd57d0710d9e06c381b550c06e76992472a8c6d527aecd2fc673dcc231fb" dependencies = [ "percent-encoding 2.3.0", - "time 0.3.24", + "time 0.3.25", "version_check", ] @@ -801,9 +801,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8810e7e2cf385b1e9b50d68264908ec367ba642c96d02edfe61c39e88e2a3c01" +checksum = "7684a49fb1af197853ef7b2ee694bc1f5b4179556f1e5710e1760c5db6f5e929" [[package]] name = "derive_more" @@ -3000,9 +3000,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b79eabcd964882a646b3584543ccabeae7869e9ac32a46f6f22b7a5bd405308b" +checksum = "b0fdd63d58b18d663fbdf70e049f00a22c8e42be082203be7f26589213cd75ea" dependencies = [ "deranged", "itoa 1.0.9", @@ -3519,7 +3519,7 @@ dependencies = [ [[package]] name = "websurfx" -version = "0.16.0" +version = "0.16.2" dependencies = [ "actix-files", "actix-web", diff --git a/Cargo.toml b/Cargo.toml index ec8d159..68398fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "websurfx" -version = "0.16.0" +version = "0.16.2" edition = "2021" description = "An open-source alternative to Searx that provides clean, ad-free, and organic results with incredible speed while keeping privacy and security in mind." repository = "https://github.com/neon-mmd/websurfx" From 653d08c80167477f4011cdb157af9ecbaeb1504a Mon Sep 17 00:00:00 2001 From: neon_arch Date: Sat, 5 Aug 2023 19:16:27 +0300 Subject: [PATCH 03/13] =?UTF-8?q?=F0=9F=94=A7=20chore:=20fix=20link=20in?= =?UTF-8?q?=20the=20logs=20&=20add=20logs=20for=20engine=20error=20(#170)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bin/websurfx.rs | 2 +- src/config/parser.rs | 2 +- src/results/aggregator.rs | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bin/websurfx.rs b/src/bin/websurfx.rs index b4b989e..6807749 100644 --- a/src/bin/websurfx.rs +++ b/src/bin/websurfx.rs @@ -24,8 +24,8 @@ async fn main() -> std::io::Result<()> { ); log::info!( "Open http://{}:{}/ in your browser", + config.binding_ip, config.port, - config.binding_ip ); let listener = TcpListener::bind((config.binding_ip.clone(), config.port))?; diff --git a/src/config/parser.rs b/src/config/parser.rs index 33421b0..201e579 100644 --- a/src/config/parser.rs +++ b/src/config/parser.rs @@ -98,7 +98,7 @@ impl Config { let threads: u8 = if parsed_threads == 0 { let total_num_of_threads: usize = available_parallelism()?.get() / 2; log::error!("Config Error: The value of `threads` option should be a non zero positive integer"); - log::info!("Falling back to using {} threads", total_num_of_threads); + log::error!("Falling back to using {} threads", total_num_of_threads); total_num_of_threads as u8 } else { parsed_threads diff --git a/src/results/aggregator.rs b/src/results/aggregator.rs index b8d7346..4ffaaf5 100644 --- a/src/results/aggregator.rs +++ b/src/results/aggregator.rs @@ -144,6 +144,7 @@ pub async fn aggregate( initial = false } Err(error_type) => { + log::error!("Engine Error: {:?}", error_type); engine_errors_info.push(EngineErrorInfo::new( error_type.downcast_ref::().unwrap(), upstream_search_engines[counter].clone(), @@ -172,6 +173,7 @@ pub async fn aggregate( counter += 1 } Err(error_type) => { + log::error!("Engine Error: {:?}", error_type); engine_errors_info.push(EngineErrorInfo::new( error_type.downcast_ref::().unwrap(), upstream_search_engines[counter].clone(), From 3d9455297fc1ca2abf8db6ce7df8ea0ec7b81e51 Mon Sep 17 00:00:00 2001 From: neon_arch Date: Sat, 5 Aug 2023 19:37:29 +0300 Subject: [PATCH 04/13] =?UTF-8?q?=F0=9F=93=9C=20docs:=20add=20documentatio?= =?UTF-8?q?n=20for=20the=20new=20config=20option=20(#175)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/configuration.md | 1 + docs/installation.md | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/configuration.md b/docs/configuration.md index 90b8ce8..665d939 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -23,6 +23,7 @@ Some of the configuration options provided in the file are stated below. These a - **logging:** An option to enable or disable logs. - **debug:** An option to enable or disable debug mode. +- **threads:** The amount of threads that the app will use to run (the value should be greater than 0). ## Server diff --git a/docs/installation.md b/docs/installation.md index f77f040..8f2ee2e 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -79,6 +79,7 @@ After that edit the config.lua file located under `websurfx` directory. In the c -- ### General ### logging = true -- an option to enable or disable logs. debug = false -- an option to enable or disable debug mode. +threads = 10 -- the amount of threads that the app will use to run (the value should be greater than 0). -- ### Server ### port = "8080" -- port on which server should be launched From efa61ea9524ab953e0bf72d0f89ed5130073b3d5 Mon Sep 17 00:00:00 2001 From: neon_arch Date: Sat, 5 Aug 2023 19:48:23 +0300 Subject: [PATCH 05/13] =?UTF-8?q?=F0=9F=9A=80=20chore:=20bump=20the=20app?= =?UTF-8?q?=20version=20(#175)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 10 +++++----- Cargo.toml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4e2688a..9427ee1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2684,18 +2684,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.180" +version = "1.0.181" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea67f183f058fe88a4e3ec6e2788e003840893b91bac4559cabedd00863b3ed" +checksum = "6d3e73c93c3240c0bda063c239298e633114c69a888c3e37ca8bb33f343e9890" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.180" +version = "1.0.181" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24e744d7782b686ab3b73267ef05697159cc0e5abbed3f47f9933165e5219036" +checksum = "be02f6cb0cd3a5ec20bbcfbcbd749f57daddb1a0882dc2e46a6c236c90b977ed" dependencies = [ "proc-macro2 1.0.66", "quote 1.0.32", @@ -3534,7 +3534,7 @@ dependencies = [ [[package]] name = "websurfx" -version = "0.16.1" +version = "0.16.3" dependencies = [ "actix-cors", "actix-files", diff --git a/Cargo.toml b/Cargo.toml index bec4799..9770f76 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "websurfx" -version = "0.16.1" +version = "0.16.3" edition = "2021" description = "An open-source alternative to Searx that provides clean, ad-free, and organic results with incredible speed while keeping privacy and security in mind." repository = "https://github.com/neon-mmd/websurfx" From 8e7fa6bb971ea05a13aef198b08baab7f7e1eacb Mon Sep 17 00:00:00 2001 From: alamin655 <129589283+alamin655@users.noreply.github.com> Date: Sun, 6 Aug 2023 12:38:17 +0530 Subject: [PATCH 06/13] Update .gitpod.yml --- .gitpod.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitpod.yml b/.gitpod.yml index 4eeabff..1871734 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -1,23 +1,24 @@ --- -image: gitpod/workspace-base +image: gitpod/workspace-rust # Commands that will run on workspace start tasks: - name: Setup, Install & Build - before: apt install cargo redis-server nodejs npm -y && cargo test - init: cargo install cargo-watch - command: redis-server --port 8080 & cargo watch -q -w "." -x "run" + before: apt install redis-server nodejs npm -y + init: cargo build -r + command: redis-server --port 8080 & ./target/release/websurfx + # Ports to expose on workspace startup ports: - name: Website description: Website Preview port: 8080 - onOpen: open-preview + onOpen: notify # vscode IDE setup vscode: extensions: - vadimcn.vscode-lldb - cschleiden.vscode-github-actions - - rust-lang.rust + - rust-lang.rust-analyzer - bungcip.better-toml - serayuzgur.crates - usernamehw.errorlens @@ -26,7 +27,6 @@ vscode: - stylelint.vscode-stylelint - dbaeumer.vscode-eslint - evgeniypeshkov.syntax-highlighter - - redhat.vscode-yaml - ms-azuretools.vscode-docker - Catppuccin.catppuccin-vsc - PKief.material-icon-theme From 5b12b7bbe8ee86f7d60f604d4843ababf9790eb5 Mon Sep 17 00:00:00 2001 From: alamin655 <129589283+alamin655@users.noreply.github.com> Date: Sun, 6 Aug 2023 13:55:51 +0530 Subject: [PATCH 07/13] Update .gitpod.yml --- .gitpod.yml | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/.gitpod.yml b/.gitpod.yml index 1871734..c26dd43 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -1,18 +1,13 @@ --- -image: gitpod/workspace-rust +image: + file: .gitpod.Dockerfile + # Commands that will run on workspace start tasks: - - name: Setup, Install & Build - before: apt install redis-server nodejs npm -y + - name: Build & Deploy init: cargo build -r - command: redis-server --port 8080 & ./target/release/websurfx + command: redis-server --port 8082 & ./target/release/websurfx -# Ports to expose on workspace startup -ports: - - name: Website - description: Website Preview - port: 8080 - onOpen: notify # vscode IDE setup vscode: extensions: @@ -32,7 +27,9 @@ vscode: - PKief.material-icon-theme - oderwat.indent-rainbow - formulahendry.auto-rename-tag - - eamodio.gitlens + - swellaby.vscode-rust-test-adapter + - belfz.search-crates-io + github: prebuilds: master: true @@ -40,5 +37,5 @@ github: pullRequests: true pullRequestsFromForks: true addCheck: true - addComment: false + addComment: false addBadge: true From a2146861a834acb16b749b3858033150e09c98f0 Mon Sep 17 00:00:00 2001 From: alamin655 <129589283+alamin655@users.noreply.github.com> Date: Sun, 6 Aug 2023 13:56:52 +0530 Subject: [PATCH 08/13] Create .gitpod.Dockerfile --- .gitpod.Dockerfile | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .gitpod.Dockerfile diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile new file mode 100644 index 0000000..c479341 --- /dev/null +++ b/.gitpod.Dockerfile @@ -0,0 +1,3 @@ +FROM gitpod/workspace-rust + +RUN sudo install-packages redis-server nodejs npm From 9b4833aaa2e9e84bbdfd3605d1457fa6ef21a6f4 Mon Sep 17 00:00:00 2001 From: alamin655 <129589283+alamin655@users.noreply.github.com> Date: Sun, 6 Aug 2023 17:44:03 +0530 Subject: [PATCH 09/13] chore: bump the app version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 9770f76..0f921bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "websurfx" -version = "0.16.3" +version = "0.16.4" edition = "2021" description = "An open-source alternative to Searx that provides clean, ad-free, and organic results with incredible speed while keeping privacy and security in mind." repository = "https://github.com/neon-mmd/websurfx" From cb473cf9f26245b5645722bfc4190c837b71d71d Mon Sep 17 00:00:00 2001 From: alamin655 <129589283+alamin655@users.noreply.github.com> Date: Sun, 6 Aug 2023 17:51:11 +0530 Subject: [PATCH 10/13] chore: bump the app version --- Cargo.lock | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9427ee1..96812fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2090,9 +2090,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" +checksum = "2c516611246607d0c04186886dbb3a754368ef82c79e9827a802c6d836dd111c" [[package]] name = "pin-utils" @@ -2391,9 +2391,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.1" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575" +checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a" dependencies = [ "aho-corasick", "memchr", @@ -2403,9 +2403,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.4" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7b6d6190b7594385f61bd3911cd1be99dfddcfc365a4160cc2ab5bff4aed294" +checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69" dependencies = [ "aho-corasick", "memchr", @@ -2539,9 +2539,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.6" +version = "0.38.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee020b1716f0a80e2ace9b03441a749e402e86712f15f16fe8a8f75afac732f" +checksum = "172891ebdceb05aa0005f533a6cbfca599ddd7d966f6f5d4d9b2e70478e70399" dependencies = [ "bitflags 2.3.3", "errno", @@ -2684,18 +2684,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.181" +version = "1.0.182" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d3e73c93c3240c0bda063c239298e633114c69a888c3e37ca8bb33f343e9890" +checksum = "bdb30a74471f5b7a1fa299f40b4bf1be93af61116df95465b2b5fc419331e430" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.181" +version = "1.0.182" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be02f6cb0cd3a5ec20bbcfbcbd749f57daddb1a0882dc2e46a6c236c90b977ed" +checksum = "6f4c2c6ea4bc09b5c419012eafcdb0fcef1d9119d626c8f3a0708a5b92d38a70" dependencies = [ "proc-macro2 1.0.66", "quote 1.0.32", @@ -3534,7 +3534,7 @@ dependencies = [ [[package]] name = "websurfx" -version = "0.16.3" +version = "0.16.4" dependencies = [ "actix-cors", "actix-files", From 2adf9aa9c379dd9dec252e076eb8bee9bbd86e88 Mon Sep 17 00:00:00 2001 From: alamin655 <129589283+alamin655@users.noreply.github.com> Date: Sun, 6 Aug 2023 17:59:37 +0530 Subject: [PATCH 11/13] Update .gitpod.yml --- .gitpod.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitpod.yml b/.gitpod.yml index c26dd43..6822d0b 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -29,6 +29,8 @@ vscode: - formulahendry.auto-rename-tag - swellaby.vscode-rust-test-adapter - belfz.search-crates-io + - hbenl.test-adapter-converter + - hbenl.vscode-test-explorer github: prebuilds: From d4bb6ecb5742ece55b58b2e8da895abd911765a9 Mon Sep 17 00:00:00 2001 From: alamin655 <129589283+alamin655@users.noreply.github.com> Date: Sun, 6 Aug 2023 20:52:29 +0530 Subject: [PATCH 12/13] Add gitlens extension Co-authored-by: neon_arch --- .gitpod.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitpod.yml b/.gitpod.yml index 6822d0b..e82d97a 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -31,7 +31,7 @@ vscode: - belfz.search-crates-io - hbenl.test-adapter-converter - hbenl.vscode-test-explorer - + - eamodio.gitlens github: prebuilds: master: true From 23864c01c104531a1b3cd0af76c11c23725f0cd2 Mon Sep 17 00:00:00 2001 From: alamin655 <129589283+alamin655@users.noreply.github.com> Date: Sun, 6 Aug 2023 21:13:28 +0530 Subject: [PATCH 13/13] Update .gitpod.yml --- .gitpod.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.gitpod.yml b/.gitpod.yml index e82d97a..d1b8f3b 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -4,9 +4,15 @@ image: # Commands that will run on workspace start tasks: - - name: Build & Deploy - init: cargo build -r - command: redis-server --port 8082 & ./target/release/websurfx + - name: Start Redis Server + command: redis-server --port 8082 + - name: Run The App + init: cargo build + command: PKG_ENV=dev ./target/release/websurfx + - name: Tests + command: cargo test + - name: Clippy Checks + command: cargo clippy # vscode IDE setup vscode: @@ -32,6 +38,7 @@ vscode: - hbenl.test-adapter-converter - hbenl.vscode-test-explorer - eamodio.gitlens + github: prebuilds: master: true