Merge branch 'main' of github.com:generalbots/generalbots

This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2026-04-29 07:12:48 -03:00
commit cd643f8f26
14 changed files with 234 additions and 156 deletions

View file

@ -1,6 +1,9 @@
[build] [build]
rustc-wrapper = "sccache" rustc-wrapper = "sccache"
jobs = 12 jobs = 6
[target.x86_64-unknown-linux-gnu] [target.x86_64-unknown-linux-gnu]
linker = "clang" linker = "clang"
rustflags = [
"-C", "link-arg=-fuse-ld=mold"
]

View file

@ -15,50 +15,50 @@ jobs:
build: build:
runs-on: gbo runs-on: gbo
env: env:
CARGO_TARGET_DIR: /opt/gbo/work/target RUSTC_WRAPPER: sccache
RUSTC_WRAPPER: "" CARGO_INCREMENTAL: "0"
PATH: /home/gbuser/.cargo/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/sbin:/bin PATH: /home/gbuser/.cargo/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/sbin:/bin
STAGE_SYSTEM_HOST: "system"
SYSTEM_USER: gbuser
CARGO_BUILD_JOBS=8
steps: steps:
- name: Setup - name: Setup
run: | run: |
cd /opt/gbo/work/generalbots cd /opt/gbo/work/generalbots
git reset --hard HEAD
git clean -fd
git pull git pull
git submodule update --init --recursive git submodule update --init --recursive
git ls-files -z | xargs -0 touch -d "@$(git log -1 --format='%ct')"
git log --oneline -1
- name: Build BotServer and BotUI - name: Build BotServer and BotUI
run: | run: |
cd /opt/gbo/work/generalbots cd /opt/gbo/work/generalbots
cargo build -p botserver --bin botserver rustup default stable
cargo build -p botui --bin botui export RUSTC_WRAPPER=sccache
echo "=== sccache stats before build ==="
sccache --show-stats 2>/dev/null || echo "sccache not available"
CARGO_BUILD_JOBS=6 cargo build -p botserver --bin botserver
CARGO_BUILD_JOBS=6 cargo build -p botui --bin botui --release
echo "=== sccache stats after build ==="
sccache --show-stats 2>/dev/null || echo "sccache not available"
- name: Deploy to Stage - name: Deploy to Stage
run: | run: |
echo "=== Deploying BotServer and BotUI to Stage ===" echo "=== Deploying to Stage ==="
# Copy both binaries to stage system container
scp -i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no \ scp -i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no \
/opt/gbo/work/generalbots/target/debug/botserver \ /opt/gbo/work/generalbots/target/debug/botserver \
${SYSTEM_USER}@${STAGE_SYSTEM_HOST}:/opt/gbo/bin/botserver-new gbuser@system:/opt/gbo/bin/botserver-new
scp -i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no \ scp -i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no \
/opt/gbo/work/generalbots/target/debug/botui \ /opt/gbo/work/generalbots/target/release/botui \
${SYSTEM_USER}@${STAGE_SYSTEM_HOST}:/opt/gbo/bin/botui-new gbuser@system:/opt/gbo/bin/botui-new
# Restart services on stage
ssh -i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no \ ssh -i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no \
${SYSTEM_USER}@${STAGE_SYSTEM_HOST} "\ gbuser@system \
"sudo systemctl stop botserver || true && \
sudo systemctl stop botserver && sudo systemctl stop botui sudo systemctl stop ui || true && \
sudo killall botui -9 & sudo killall botserver -9 sudo mv /opt/gbo/bin/botserver-new /opt/gbo/bin/botserver && \
sudo mv /opt/gbo/bin/botserver-new /opt/gbo/bin/botserver && \ sudo mv /opt/gbo/bin/botui-new /opt/gbo/bin/botui && \
sudo mv /opt/gbo/bin/botui-new /opt/gbo/bin/botui && \ sudo chmod +x /opt/gbo/bin/botserver /opt/gbo/bin/botui && \
sudo chmod +x /opt/gbo/bin/botserver /opt/gbo/bin/botui && \ sudo systemctl start botserver && \
sudo systemctl start botserver && \ sudo systemctl start ui"
sudo systemctl start ui" sleep 10
ssh -i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no \
gbuser@system \
"curl -sf http://localhost:8080/health && echo 'BotServer OK' || echo 'BotServer FAILED'; \
curl -sf http://localhost:3000/ && echo 'BotUI OK' || echo 'BotUI FAILED'"

View file

@ -224,6 +224,11 @@ result = DETECT "folha_salarios"
## 💬 Common BASIC Keywords Reference ## 💬 Common BASIC Keywords Reference
### Language Guidelines
- Use formal language in all comments and documentation
- Avoid slang, neologisms, or informal expressions
- Maintain professional tone in code comments
### TALK - Bot Response ### TALK - Bot Response
```basic ```basic

View file

@ -1,53 +1,20 @@
#!/bin/bash #!/bin/bash
set -e set -e
[ "$EUID" -ne 0 ] && { echo "Run as root (use sudo)"; exit 1; }
if [ "$EUID" -ne 0 ]; then
echo "Run as root (use sudo)"
exit 1
fi
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
echo "Installing runtime dependencies first..."
bash "$SCRIPT_DIR/DEPENDENCIES.sh" bash "$SCRIPT_DIR/DEPENDENCIES.sh"
echo "Installing dev/build dependencies..."
OS=$(grep -oP '(?<=^ID=).+' /etc/os-release 2>/dev/null | tr -d '"' || echo "unknown") OS=$(grep -oP '(?<=^ID=).+' /etc/os-release 2>/dev/null | tr -d '"' || echo "unknown")
install_debian() { apt-get install -y -qq clang lld build-essential pkg-config libssl-dev libpq-dev cmake git libglib2.0-dev libgtk-3-dev libwebkit2gtk-4.1-dev libjavascriptcoregtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev libsoup-3.0-dev; }
install_debian() { install_fedora() { dnf install -y -q clang lld gcc gcc-c++ make pkg-config openssl-devel postgresql-devel cmake git glib2-devel gobject-introspection-devel gtk3-devel webkit2gtk3-devel javascriptcoregtk-devel libappindicator-gtk3-devel librsvg2-devel libsoup3-devel; }
apt-get install -y -qq \ install_arch() { pacman -Sy --noconfirm clang lld gcc make pkg-config openssl libpq cmake git glib2 gtk3 webkit2gtk4 javascriptcoregtk libappindicator librsvg libsoup; }
clang lld build-essential pkg-config libssl-dev libpq-dev cmake git \
libglib2.0-dev libgtk-3-dev libwebkit2gtk-4.1-dev libjavascriptcoregtk-4.1-dev \
libayatana-appindicator3-dev librsvg2-dev libsoup-3.0-dev
}
install_fedora() {
dnf install -y -q \
clang lld gcc gcc-c++ make pkg-config openssl-devel postgresql-devel cmake git \
glib2-devel gobject-introspection-devel gtk3-devel webkit2gtk3-devel \
javascriptcoregtk-devel libappindicator-gtk3-devel librsvg2-devel libsoup3-devel
}
install_arch() {
pacman -Sy --noconfirm \
clang lld gcc make pkg-config openssl libpq cmake git \
glib2 gtk3 webkit2gtk4 javascriptcoregtk libappindicator librsvg libsoup
}
case $OS in case $OS in
ubuntu|debian|linuxmint|pop) install_debian ;; ubuntu|debian|linuxmint|pop) install_debian ;;
fedora|rhel|centos|rocky|almalinux) install_fedora ;; fedora|rhel|centos|rocky|almalinux) install_fedora ;;
arch|manjaro) install_arch ;; arch|manjaro) install_arch ;;
*) echo "Unsupported OS: $OS"; exit 1 ;; *) echo "Unsupported OS: $OS"; exit 1 ;;
esac esac
install_mold() { curl -L "https://github.com/rui314/mold/releases/download/v2.4.0/mold-2.4.0-x86_64-linux.tar.gz" -o /tmp/mold.tar.gz; tar -xzf /tmp/mold.tar.gz -C /tmp; cp "/tmp/mold-2.4.0-x86_64-linux/bin/mold" /usr/local/bin/; rm -rf /tmp/mold-2.4.0* /tmp/mold.tar.gz; ldconfig; }
install_mold() {
curl -L "https://github.com/rui314/mold/releases/download/v2.4.0/mold-2.4.0-x86_64-linux.tar.gz" -o /tmp/mold.tar.gz
tar -xzf /tmp/mold.tar.gz -C /tmp
cp "/tmp/mold-2.4.0-x86_64-linux/bin/mold" /usr/local/bin/
rm -rf /tmp/mold-2.4.0* /tmp/mold.tar.gz
ldconfig
}
command -v mold &> /dev/null || install_mold command -v mold &> /dev/null || install_mold
echo "✅ Tools: clang, lld, mold, sccache"
echo "Dev dependencies installed!" echo "📦 Workspace .cargo/config.toml will be used"
echo "⚡ Build: cargo build -p botserver --bin botserver"

View file

@ -29,7 +29,10 @@ class AnomalyResult(BaseModel):
@app.get("/health") @app.get("/health")
def health(): def health():
return {"status": "healthy", "service": "anomaly-detection"} return {"status": "healthy", "service": "anomaly-detection", "commit": os.environ.get("BOTMODELS_COMMIT", "unknown")}
import os
@app.post("/api/detect", response_model=AnomalyResult) @app.post("/api/detect", response_model=AnomalyResult)

View file

@ -20,6 +20,7 @@ class Settings(BaseSettings):
project_name: str = "BotModels API" project_name: str = "BotModels API"
version: str = "2.0.0" version: str = "2.0.0"
api_key: str = "change-me" api_key: str = "change-me"
commit: str = "unknown"
# External Providers for Speech (Optional) # External Providers for Speech (Optional)
groq_api_key: Optional[str] = None groq_api_key: Optional[str] = None

View file

@ -62,6 +62,7 @@ async def root():
{ {
"service": settings.project_name, "service": settings.project_name,
"version": settings.version, "version": settings.version,
"commit": settings.commit,
"status": "running", "status": "running",
"docs": "/api/docs", "docs": "/api/docs",
"endpoints": { "endpoints": {
@ -78,7 +79,12 @@ async def root():
@app.get("/api/health") @app.get("/api/health")
async def health(): async def health():
return {"status": "healthy", "version": settings.version, "device": settings.device} return {
"status": "healthy",
"version": settings.version,
"commit": settings.commit,
"device": settings.device,
}
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -1,15 +1,48 @@
fn main() { fn main() {
if std::path::Path::new("../botui/ui/suite/").exists() { if std::path::Path::new("../botui/ui/suite/").exists() {
println!("cargo:rerun-if-changed=../botui/ui/suite/"); println!("cargo:rerun-if-changed=../botui/ui/suite/");
} }
println!("cargo:rerun-if-changed=3rdparty.toml"); println!("cargo:rerun-if-changed=3rdparty.toml");
println!("cargo:rerun-if-changed=.env.embedded"); println!("cargo:rerun-if-changed=.env.embedded");
// Pass build metadata to the binary via option_env! if let Ok(date) = std::env::var("BOTSERVER_BUILD_DATE") {
if let Ok(date) = std::env::var("BOTSERVER_BUILD_DATE") { println!("cargo:rustc-env=BOTSERVER_BUILD_DATE={}", date);
println!("cargo:rustc-env=BOTSERVER_BUILD_DATE={}", date); } else {
} println!("cargo:rustc-env=BOTSERVER_BUILD_DATE={}", chrono_now());
if let Ok(commit) = std::env::var("BOTSERVER_COMMIT") { }
println!("cargo:rustc-env=BOTSERVER_COMMIT={}", commit);
} let commit = std::env::var("BOTSERVER_COMMIT")
.ok()
.or_else(|| git_commit_hash());
if let Some(hash) = commit {
println!("cargo:rustc-env=BOTSERVER_COMMIT={}", hash);
}
}
fn git_commit_hash() -> Option<String> {
let output = std::process::Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output()
.ok()?;
if !output.status.success() {
return None;
}
String::from_utf8(output.stdout).ok().map(|s| s.trim().to_string())
}
fn chrono_now() -> String {
let output = match std::process::Command::new("date")
.args(["+%Y-%m-%dT%H:%M:%S"])
.output()
{
Ok(o) => o,
Err(_) => return "unknown".to_string(),
};
if !output.status.success() {
return "unknown".to_string();
}
String::from_utf8(output.stdout)
.ok()
.map(|s| s.trim().to_string())
.unwrap_or_else(|| "unknown".to_string())
} }

View file

@ -1,6 +1,6 @@
// Bootstrap manager implementation // Bootstrap manager implementation
use crate::core::bootstrap::bootstrap_types::{BootstrapManager, BootstrapProgress}; use crate::core::bootstrap::bootstrap_types::{BootstrapManager, BootstrapProgress};
use crate::core::bootstrap::bootstrap_utils::{alm_ci_health_check, alm_health_check, cache_health_check, drive_health_check, safe_pkill, tables_health_check, vault_health_check, vector_db_health_check, zitadel_health_check}; use crate::core::bootstrap::bootstrap_utils::{alm_health_check, cache_health_check, drive_health_check, safe_pkill, tables_health_check, vault_health_check, vector_db_health_check, zitadel_health_check};
use crate::core::config::AppConfig; use crate::core::config::AppConfig;
use crate::core::package_manager::{InstallMode, PackageManager}; use crate::core::package_manager::{InstallMode, PackageManager};
use crate::core::shared::utils::get_stack_path; use crate::core::shared::utils::get_stack_path;
@ -260,22 +260,23 @@ impl BootstrapManager {
} }
} }
if pm.is_installed("alm-ci") { // TEMP DISABLED: ALM CI startup hangs bootstrap
let alm_ci_already_running = alm_ci_health_check(); // if pm.is_installed("alm-ci") {
if alm_ci_already_running { // let alm_ci_already_running = alm_ci_health_check();
info!("ALM CI (Forgejo Runner) is already running"); // if alm_ci_already_running {
} else { // info!("ALM CI (Forgejo Runner) is already running");
info!("Starting ALM CI (Forgejo Runner) service..."); // } else {
match pm.start("alm-ci") { // info!("Starting ALM CI (Forgejo Runner) service...");
Ok(_child) => { // match pm.start("alm-ci") {
info!("ALM CI service started"); // Ok(_child) => {
} // info!("ALM CI service started");
Err(e) => { // }
warn!("Failed to start ALM CI service: {}", e); // Err(e) => {
} // warn!("Failed to start ALM CI service: {}", e);
} // }
} // }
} // }
// }
// Caddy is the web server // Caddy is the web server
let caddy_cmd = SafeCommand::new("caddy") let caddy_cmd = SafeCommand::new("caddy")

View file

@ -1693,18 +1693,21 @@ VAULT_CACERT={}
("smtp_from".to_string(), "none".to_string()), ("smtp_from".to_string(), "none".to_string()),
], ],
), ),
( (
"secret/gbo/llm", "secret/gbo/llm",
vec![ vec![
("url".to_string(), "".to_string()), ("url".to_string(), "".to_string()),
("host".to_string(), "localhost".to_string()), ("host".to_string(), "localhost".to_string()),
("port".to_string(), "8081".to_string()), ("port".to_string(), "8081".to_string()),
("model".to_string(), "gpt-4".to_string()), ("model".to_string(), "gpt-4".to_string()),
("openai_key".to_string(), "none".to_string()), ("openai_key".to_string(), "none".to_string()),
("anthropic_key".to_string(), "none".to_string()), ("anthropic_key".to_string(), "none".to_string()),
("ollama_url".to_string(), "".to_string()), ("ollama_url".to_string(), "".to_string()),
], ("embedding_url".to_string(), "http://localhost:8082/v1/embeddings".to_string()),
), ("embedding_model".to_string(), "bge-small-en-v1.5-f32.gguf".to_string()),
("embedding_port".to_string(), "8082".to_string()),
],
),
( (
"secret/gbo/encryption", "secret/gbo/encryption",
vec![("master_key".to_string(), master_key)], vec![("master_key".to_string(), master_key)],

View file

@ -61,7 +61,7 @@ pub async fn ensure_llama_servers_running(
) )
}; };
let ( let (
_default_bot_id, default_bot_id,
llm_server_enabled, llm_server_enabled,
llm_url, llm_url,
llm_model, llm_model,
@ -79,19 +79,44 @@ pub async fn ensure_llama_servers_running(
llm_server_path llm_server_path
}; };
let llm_model = if llm_model.is_empty() { let llm_url = if llm_url.is_empty() && llm_server_enabled {
info!("No LLM model configured, using default: DeepSeek-R1-Distill-Qwen-1.5B-Q3_K_M.gguf"); let url = "http://localhost:8081/v1/chat/completions".to_string();
"DeepSeek-R1-Distill-Qwen-1.5B-Q3_K_M.gguf".to_string() info!("No llm-url configured with local server enabled, using default: {url}");
} else { let config_manager = ConfigManager::new(app_state.conn.clone());
llm_model if let Err(e) = config_manager.set_config(&default_bot_id, "llm-url", &url) {
}; warn!("Failed to persist default llm-url: {e}");
}
url
} else {
llm_url
};
let embedding_model = if embedding_model.is_empty() { let llm_model = if llm_model.is_empty() {
info!("No embedding model configured, using default: bge-small-en-v1.5-f32.gguf"); info!("No LLM model configured, using default: DeepSeek-R1-Distill-Qwen-1.5B-Q3_K_M.gguf");
"bge-small-en-v1.5-f32.gguf".to_string() "DeepSeek-R1-Distill-Qwen-1.5B-Q3_K_M.gguf".to_string()
} else { } else {
embedding_model llm_model
}; };
let embedding_model = if embedding_model.is_empty() {
info!("No embedding model configured, using default: bge-small-en-v1.5-f32.gguf");
"bge-small-en-v1.5-f32.gguf".to_string()
} else {
embedding_model
};
let embedding_url = if embedding_url.is_empty() {
let default_port = "8082";
let url = format!("http://localhost:{default_port}/v1/embeddings");
info!("No embedding-url configured, using default: {url}");
let config_manager = ConfigManager::new(app_state.conn.clone());
if let Err(e) = config_manager.set_config(&default_bot_id, "embedding-url", &url) {
warn!("Failed to persist default embedding-url: {e}");
}
url
} else {
embedding_url
};
// For llama-server startup, use path relative to botserver root // For llama-server startup, use path relative to botserver root
// The models are in <stack_path>/data/llm/ and the llama-server runs from botserver root // The models are in <stack_path>/data/llm/ and the llama-server runs from botserver root
@ -443,7 +468,7 @@ pub fn start_llm_server(
.unwrap_or_else(|_| "32000".to_string()); .unwrap_or_else(|_| "32000".to_string());
let n_ctx_size = if n_ctx_size.is_empty() { "32000".to_string() } else { n_ctx_size }; let n_ctx_size = if n_ctx_size.is_empty() { "32000".to_string() } else { n_ctx_size };
let _cmd_path = if cfg!(windows) { let cmd_path = if cfg!(windows) {
format!("{}\\llama-server.exe", llama_cpp_path) format!("{}\\llama-server.exe", llama_cpp_path)
} else { } else {
format!("{}/llama-server", llama_cpp_path) format!("{}/llama-server", llama_cpp_path)
@ -489,12 +514,10 @@ pub fn start_llm_server(
args_vec.push(&n_ctx_size); args_vec.push(&n_ctx_size);
args_vec.push("--verbose"); args_vec.push("--verbose");
let mut command = SafeCommand::new("llama-server")?; let mut command = SafeCommand::new(&cmd_path)?;
command = command.args(&args_vec)?; command = command.args(&args_vec)?;
command = command.working_dir(std::path::Path::new(&llama_cpp_path))?;
if cfg!(windows) { command = command.env("LD_LIBRARY_PATH", &llama_cpp_path)?;
command = command.working_dir(std::path::Path::new(&llama_cpp_path))?;
}
let log_file_path = if cfg!(windows) { let log_file_path = if cfg!(windows) {
format!("{}\\llm-stdout.log", llama_cpp_path) format!("{}\\llm-stdout.log", llama_cpp_path)
@ -558,22 +581,27 @@ pub async fn start_embedding_server(
"-m", &model_path, "-m", &model_path,
"--host", "0.0.0.0", "--host", "0.0.0.0",
"--port", port, "--port", port,
"--embedding", "--embeddings",
"--pooling", "mean",
"--n-gpu-layers", "0", "--n-gpu-layers", "0",
"--verbose", "--ctx-size", "512",
]; ];
if !cfg!(windows) { if !cfg!(windows) {
args_vec.push("--ubatch-size"); args_vec.push("--ubatch-size");
args_vec.push("2048"); args_vec.push("512");
} }
let mut command = SafeCommand::new("llama-server")?; let cmd_path = if cfg!(windows) {
format!("{}\\llama-server.exe", llama_cpp_path)
} else {
format!("{}/llama-server", llama_cpp_path)
};
let mut command = SafeCommand::new(&cmd_path)?;
command = command.args(&args_vec)?; command = command.args(&args_vec)?;
command = command.working_dir(std::path::Path::new(&llama_cpp_path))?;
if cfg!(windows) { command = command.env("LD_LIBRARY_PATH", &llama_cpp_path)?;
command = command.working_dir(std::path::Path::new(&llama_cpp_path))?;
}
let log_file_path = if cfg!(windows) { let log_file_path = if cfg!(windows) {
format!("{}\\stdout.log", llama_cpp_path) format!("{}\\stdout.log", llama_cpp_path)

View file

@ -1,7 +1,7 @@
#![recursion_limit = "512"] #![recursion_limit = "512"]
// Module declarations // Module declarations
pub mod main_module; pub mod main_module; // ci-timing
// Re-export commonly used items from main_module // Re-export commonly used items from main_module
pub use main_module::{BootstrapProgress, health_check, health_check_simple, receive_client_errors}; pub use main_module::{BootstrapProgress, health_check, health_check_simple, receive_client_errors};
@ -255,6 +255,7 @@ rustls=off,rustls_pemfile=off,tokio_rustls=off,\
Ok(existing) if !existing.is_empty() => format!("{},{}", existing, noise_filters), Ok(existing) if !existing.is_empty() => format!("{},{}", existing, noise_filters),
_ => format!("info,{}", noise_filters), _ => format!("info,{}", noise_filters),
}; };
// Test mold+sccache build
std::env::set_var("RUST_LOG", &rust_log); std::env::set_var("RUST_LOG", &rust_log);
@ -433,3 +434,4 @@ rustls=off,rustls_pemfile=off,tokio_rustls=off,\
Ok(()) Ok(())
} }
// force rebuild Fri Apr 3 21:42:33 -03 2026 // force rebuild Fri Apr 3 21:42:33 -03 2026
// Force new CI run - Tue Apr 28 05:22:39 PM -03 2026

View file

@ -1,5 +1,23 @@
fn main() { fn main() {
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap(); let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
let ui_path = std::path::Path::new(&manifest_dir).join("ui"); let ui_path = std::path::Path::new(&manifest_dir).join("ui");
println!("cargo:rustc-env=BOTUI_UI_PATH={}", ui_path.display()); println!("cargo:rustc-env=BOTUI_UI_PATH={}", ui_path.display());
let commit = std::env::var("BOTUI_COMMIT")
.ok()
.or_else(|| git_commit_hash());
if let Some(hash) = commit {
println!("cargo:rustc-env=BOTUI_COMMIT={}", hash);
}
}
fn git_commit_hash() -> Option<String> {
let output = std::process::Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output()
.ok()?;
if !output.status.success() {
return None;
}
String::from_utf8(output.stdout).ok().map(|s| s.trim().to_string())
} }

View file

@ -595,13 +595,16 @@ pub fn remove_section(html: &str, section: &str) -> String {
} }
async fn health(State(state): State<AppState>) -> (StatusCode, axum::Json<serde_json::Value>) { async fn health(State(state): State<AppState>) -> (StatusCode, axum::Json<serde_json::Value>) {
let commit = option_env!("BOTUI_COMMIT").unwrap_or("unknown");
if state.health_check().await { if state.health_check().await {
( (
StatusCode::OK, StatusCode::OK,
axum::Json(serde_json::json!({ axum::Json(serde_json::json!({
"status": "healthy", "status": "healthy",
"service": "botui", "service": "botui",
"mode": "web" "mode": "web",
"version": env!("CARGO_PKG_VERSION"),
"commit": commit
})), })),
) )
} else { } else {
@ -610,20 +613,24 @@ async fn health(State(state): State<AppState>) -> (StatusCode, axum::Json<serde_
axum::Json(serde_json::json!({ axum::Json(serde_json::json!({
"status": "unhealthy", "status": "unhealthy",
"service": "botui", "service": "botui",
"error": "botserver unreachable" "error": "botserver unreachable",
"version": env!("CARGO_PKG_VERSION"),
"commit": commit
})), })),
) )
} }
} }
async fn api_health(State(state): State<AppState>) -> (StatusCode, axum::Json<serde_json::Value>) { async fn api_health(State(state): State<AppState>) -> (StatusCode, axum::Json<serde_json::Value>) {
let commit = option_env!("BOTUI_COMMIT").unwrap_or("unknown");
if state.health_check().await { if state.health_check().await {
( (
StatusCode::OK, StatusCode::OK,
axum::Json(serde_json::json!({ axum::Json(serde_json::json!({
"status": "ok", "status": "ok",
"botserver": "healthy", "botserver": "healthy",
"version": env!("CARGO_PKG_VERSION") "version": env!("CARGO_PKG_VERSION"),
"commit": commit
})), })),
) )
} else { } else {
@ -632,7 +639,8 @@ async fn api_health(State(state): State<AppState>) -> (StatusCode, axum::Json<se
axum::Json(serde_json::json!({ axum::Json(serde_json::json!({
"status": "error", "status": "error",
"botserver": "unhealthy", "botserver": "unhealthy",
"version": env!("CARGO_PKG_VERSION") "version": env!("CARGO_PKG_VERSION"),
"commit": commit
})), })),
) )
} }