Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added services/.DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions services/client/src/script.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const backendURL = `https://api.moogle.app/api`;
// const backendURL = `http://127.0.0.1:8000/api`;
// const backendURL = `https://api.moogle.app/api`;
const backendURL = `http://127.0.0.1:8000/api`;

document.addEventListener("DOMContentLoaded", () => {
const searchButton = document.getElementById("search-button");
Expand Down
36 changes: 30 additions & 6 deletions services/client/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ body {

.main-container {
@apply flex flex-col items-center justify-center min-h-100 gap-y-4;
min-height: 60vh;
}

.logo-container {
color: var(--accent);
font-size: 7em;
font-size: clamp(3em,10vw,7em);
@apply drop-shadow-lg font-semibold;
-webkit-text-stroke: 0.1rem white;
text-shadow:
Expand All @@ -46,7 +47,7 @@ body {
border-right: solid var(--buton-down) 0.2rem;
border-bottom: solid var(--buton-down) 0.2rem;
box-shadow: 0 0 0 0.2rem black;
@apply text-lg font-semibold drop-shadow-lg p-2;
@apply text-lg font-semibold drop-shadow-lg p-2 w-full sm:w-auto;
/* @apply border border-gray-400 py-2 px-2 bg-slate-300 rounded shadow; */
}

Expand Down Expand Up @@ -82,7 +83,7 @@ body {
#search-bar {
background-color: var(--text);
color: var(--bg);
@apply border border-gray-400 w-140 h-10 px-2;
@apply border border-gray-400 w-full max-w-[600px] h-10 px-2;
}

#search-bar:disabled {
Expand All @@ -91,22 +92,26 @@ body {

/* FOOTER */
footer {
@apply mt-20 py-4 text-center text-sm w-full;
@apply mt-10 sm:mt-20 py-4 text-center text-sm w-full px-4;
}

footer p {
@apply text-sm;
@apply text-sm mb-2;
}

footer a {
color: var(--accent);
@apply hover:underline;
@apply hover:underline inline-block mx-1;
}

#copyright {
@apply text-xs mt-5;
}

#info-container {
@apply text-center px-4 mt-4;
}

.info {
color: var(--orange);
@apply text-base;
Expand Down Expand Up @@ -148,3 +153,22 @@ body::before {
background-size: 100% 4px;
}
}

@media (max-width: 640px) {
.main-container {
padding: 1rem;
}

.btn {
font-size: 1rem;
padding: 0.75rem;
}

#search-bar {
height: 2.5rem;
}

footer {
font-size: 0.875rem;
}
}
10 changes: 5 additions & 5 deletions services/indexer/data/mongo_client.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import time
import logging
import time
from typing import Dict, List, Optional, Set

import pymongo
from pymongo import UpdateOne

from typing import Optional, List, Set, Dict
from models.page import Page
from models.metadata import Metadata
from models.outlinks import Outlinks

from pymongo import UpdateOne
from models.page import Page

# SETUP LOGGER
logger = logging.getLogger(__name__)
Expand Down
Binary file added services/indexer/dump.rdb
Binary file not shown.
61 changes: 38 additions & 23 deletions services/monitoring/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
extern crate redis;
use redis::Commands;
use std::env;
use std::{thread, time};
use std::process::Command;
use std::process;

use std::process::Command;
use std::{thread, time};

fn main() {
// Get environment variable
let redis_host = env::var("REDIS_HOST").expect("REDIS_HOST environment variable not set");
let redis_port = env::var("REDIS_PORT").unwrap_or_else(|_| "6379".to_string());
let redis_password = env::var("REDIS_PASSWORD").unwrap_or_else(|_| "".to_string());
let redis_db : u8 = env::var("REDIS_DB").unwrap_or("0".to_string()).parse().expect("REDIS_DB must be a valid integer");
let redis_db: u8 = env::var("REDIS_DB")
.unwrap_or("0".to_string())
.parse()
.expect("REDIS_DB must be a valid integer");

// Build the Redis URL
let mut redis_url = format!("redis://{}:{}", redis_host, redis_port);
Expand Down Expand Up @@ -63,9 +65,12 @@ fn main() {
}

// Get the length of the url_queue
let url_queue_length: usize = con.zcard("spider_queue").expect("Failed to get queue length");
let url_queue_length: usize = con
.zcard("spider_queue")
.expect("Failed to get queue length");
// Get the length of the indexer_queue
let indexer_queue_length: usize = con.llen("pages_queue").expect("Failed to get queue length");
let indexer_queue_length: usize =
con.llen("pages_queue").expect("Failed to get queue length");
// Get the count of backlinks keys
let backlinks_count: usize = get_backlinks_count(&mut con);

Expand Down Expand Up @@ -97,8 +102,8 @@ fn main() {
1
} else {
std::cmp::min(
max_indexers,
(1.5 * (indexer_queue_length as f64 / 100.0)).ceil() as usize
max_indexers,
(1.5 * (indexer_queue_length as f64 / 100.0)).ceil() as usize,
)
}
};
Expand All @@ -110,10 +115,17 @@ fn main() {
scale_indexers(desired_indexers);

// Scale backlinks processors
let desired_backlinks_processors = calculate_desired_backlinks_processors(backlinks_count, max_backlinks_processors);
let desired_backlinks_processors =
calculate_desired_backlinks_processors(backlinks_count, max_backlinks_processors);
let current_backlinks_processors = get_current_backlinks_processors();
println!("| Current backlinks processors: {}", current_backlinks_processors);
println!("|\tDesired backlinks processors count: {}", desired_backlinks_processors);
println!(
"| Current backlinks processors: {}",
current_backlinks_processors
);
println!(
"|\tDesired backlinks processors count: {}",
desired_backlinks_processors
);
scale_backlinks_processors(desired_backlinks_processors);

println!("|--------------------------------------|");
Expand Down Expand Up @@ -163,7 +175,7 @@ fn scale_backlinks_processors(desired_processors: usize) {
Command::new("docker")
.arg("compose")
.arg("-f")
.arg("../backlinks-processor/docker-compose.yml") // Specify the backlinks service compose file
.arg("../backlinks-processor/docker-compose.yml") // Specify the backlinks service compose file
.arg("up")
//.arg("--scale")
//.arg(format!("backlinks-processor={}", desired_processors))
Expand All @@ -177,14 +189,15 @@ fn get_current_backlinks_processors() -> usize {
let output = Command::new("docker")
.arg("compose")
.arg("-f")
.arg("../backlinks-processor/docker-compose.yml") // Specify the backlinks service compose file
.arg("../backlinks-processor/docker-compose.yml") // Specify the backlinks service compose file
.arg("ps")
.output()
.expect("Failed to get Docker Compose services");

let output_str = String::from_utf8_lossy(&output.stdout);

output_str.split('\n')
output_str
.split('\n')
.filter(|line| line.contains("backlinks-processor"))
.count()
}
Expand All @@ -194,7 +207,7 @@ fn stop_backlinks_processors() {
Command::new("docker")
.arg("compose")
.arg("-f")
.arg("../backlinks-processor/docker-compose.yml") // Specify the backlinks service compose file
.arg("../backlinks-processor/docker-compose.yml") // Specify the backlinks service compose file
.arg("down")
.status()
.expect("Failed to stop backlinks processors");
Expand All @@ -216,7 +229,7 @@ fn scale_spiders(desired_spiders: usize) {
Command::new("docker")
.arg("compose")
.arg("-f")
.arg("../spider/docker-compose.yml") // Specify the indexer service compose file
.arg("../spider/docker-compose.yml") // Specify the indexer service compose file
.arg("up")
.arg("--scale")
.arg(format!("spider-service={}", desired_spiders))
Expand All @@ -230,14 +243,15 @@ fn get_current_spiders() -> usize {
let output = Command::new("docker")
.arg("compose")
.arg("-f")
.arg("../spider/docker-compose.yml") // Specify the indexer service compose file
.arg("../spider/docker-compose.yml") // Specify the indexer service compose file
.arg("ps")
.output()
.expect("Failed to get Docker Compose services");

let output_str = String::from_utf8_lossy(&output.stdout);

output_str.split('\n')
output_str
.split('\n')
.filter(|line| line.contains("spider-service"))
.count()
}
Expand All @@ -250,7 +264,7 @@ fn scale_indexers(desired_indexers: usize) {
Command::new("docker")
.arg("compose")
.arg("-f")
.arg("../indexer/docker-compose.yml") // Specify the indexer service compose file
.arg("../indexer/docker-compose.yml") // Specify the indexer service compose file
.arg("up")
.arg("--scale")
.arg(format!("indexer-service={}", desired_indexers))
Expand All @@ -265,7 +279,7 @@ fn stop_indexers() {
Command::new("docker")
.arg("compose")
.arg("-f")
.arg("../indexer/docker-compose.yml") // Specify the indexer service compose file
.arg("../indexer/docker-compose.yml") // Specify the indexer service compose file
.arg("down")
.status()
.expect("Failed to stop indexers");
Expand All @@ -276,7 +290,7 @@ fn stop_spiders() {
Command::new("docker")
.arg("compose")
.arg("-f")
.arg("../spider/docker-compose.yml") // Specify the indexer service compose file
.arg("../spider/docker-compose.yml") // Specify the indexer service compose file
.arg("down")
.status()
.expect("Failed to stop spiders");
Expand All @@ -286,14 +300,15 @@ fn get_current_indexers() -> usize {
let output = Command::new("docker")
.arg("compose")
.arg("-f")
.arg("../indexer/docker-compose.yml") // Specify the indexer service compose file
.arg("../indexer/docker-compose.yml") // Specify the indexer service compose file
.arg("ps")
.output()
.expect("Failed to get Docker Compose services");

let output_str = String::from_utf8_lossy(&output.stdout);

output_str.split('\n')
output_str
.split('\n')
.filter(|line| line.contains("indexer-service"))
.count()
}
Binary file added services/query-engine/.DS_Store
Binary file not shown.
Loading