Merge branch 'main' of https://alm.pragmatismo.com.br/GeneralBots/generalbots
All checks were successful
Botlib CI / build (push) Successful in 18s
Bottest CI / build (push) Successful in 40s
BotUI CI / build (push) Successful in 20s

This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2026-04-24 15:37:47 +00:00
commit 02aaf528a9
2 changed files with 56 additions and 32 deletions

View file

@ -25,17 +25,11 @@ jobs:
run: |
cd /opt/gbo/work/generalbots
CARGO_BUILD_JOBS=4 cargo build -p botserver --bin botserver
- name: Deploy to Stage
run: |
BINARY=/opt/gbo/work/target/debug/botserver
ssh -o StrictHostKeyChecking=no ${SYSTEM_USER}@${SYSTEM_HOST} "sudo systemctl stop botserver 2>/dev/null; sudo pkill -x botserver 2>/dev/null; sleep 1"
scp -o StrictHostKeyChecking=no "$BINARY" ${SYSTEM_USER}@${SYSTEM_HOST}:/opt/gbo/bin/botserver-new
ssh -o StrictHostKeyChecking=no ${SYSTEM_USER}@${SYSTEM_HOST} "sudo mv /opt/gbo/bin/botserver-new /opt/gbo/bin/botserver && sudo chmod +x /opt/gbo/bin/botserver && sudo systemctl enable botserver && sudo systemctl start botserver"
sleep 10
ssh -o StrictHostKeyChecking=no ${SYSTEM_USER}@${SYSTEM_HOST} "curl -sf http://localhost:8080/health && echo 'BotServer Deployed' || echo 'Failed'"
- name: Sync UI Files to Stage
run: |
# Sync UI files - botserver reads from /opt/gbo/botui/ui/
rsync -az --delete -e "ssh -o StrictHostKeyChecking=no" /opt/gbo/work/generalbots/botui/ui/ ${SYSTEM_USER}@${SYSTEM_HOST}:/opt/gbo/botui/ui/
# Verify sync
ssh -o StrictHostKeyChecking=no ${SYSTEM_USER}@${SYSTEM_HOST} "wc -c /opt/gbo/botui/ui/suite/chat/chat.html"
- name: Deploy to Stage
run: |
BINARY=/opt/gbo/work/target/debug/botserver
ssh -o StrictHostKeyChecking=no ${SYSTEM_USER}@${SYSTEM_HOST} "sudo systemctl stop botserver 2>/dev/null; sudo pkill -x botserver 2>/dev/null; sleep 1"
scp -o StrictHostKeyChecking=no "$BINARY" ${SYSTEM_USER}@${SYSTEM_HOST}:/opt/gbo/bin/botserver-new
ssh -o StrictHostKeyChecking=no ${SYSTEM_USER}@${SYSTEM_HOST} "sudo mv /opt/gbo/bin/botserver-new /opt/gbo/bin/botserver && sudo chmod +x /opt/gbo/bin/botserver && sudo systemctl enable botserver && sudo systemctl start botserver"
sleep 10
ssh -o StrictHostKeyChecking=no ${SYSTEM_USER}@${SYSTEM_HOST} "curl -sf http://localhost:8080/health && echo 'BotServer Deployed' || echo 'Failed'"

View file

@ -69,22 +69,27 @@ pub struct EmailConfig {
impl Default for AppConfig {
fn default() -> Self {
// Configuration loading priority: 1) Environment (from Vault via .env), 2) Defaults for development
Self {
server: ServerConfig {
host: "localhost".to_string(),
port: 8080,
base_url: "http://localhost:8080".to_string(),
host: "0.0.0.0".to_string(),
port: std::env::var("PORT")
.ok()
.and_then(|v| v.parse().ok())
.unwrap_or(8080),
base_url: String::new(),
},
database: DatabaseConfig {
url: std::env::var("DATABASE_URL").unwrap_or_else(|_| {
"postgresql://postgres:postgres@localhost/botserver".to_string()
}),
url: std::env::var("DATABASE_URL")
.unwrap_or_else(|_| "postgresql://postgres:postgres@localhost/botserver".to_string()),
max_connections: 10,
},
drive: DriveConfig::default(),
email: EmailConfig::default(),
site_path: "/opt/gbo/data".to_string(),
data_dir: "/opt/gbo/data".to_string(),
site_path: std::env::var("SITE_PATH")
.unwrap_or_else(|_| "/opt/gbo/data".to_string()),
data_dir: std::env::var("DATA_DIR")
.unwrap_or_else(|_| "/opt/gbo/data".to_string()),
}
}
}
@ -102,10 +107,30 @@ impl AppConfig {
Ok(Self::default())
}
pub fn from_env() -> Result<Self, Box<dyn std::error::Error>> {
// Try to load config from environment variables
Ok(Self::default())
}
pub fn from_env() -> Result<Self, Box<dyn std::error::Error>> {
// Configuration loading: Environment vars (from Vault via .env) with fallbacks for development
Ok(Self {
server: ServerConfig {
host: "0.0.0.0".to_string(),
port: std::env::var("PORT")
.ok()
.and_then(|v| v.parse().ok())
.unwrap_or(8080),
base_url: String::new(),
},
database: DatabaseConfig {
url: std::env::var("DATABASE_URL")
.unwrap_or_else(|_| "postgresql://postgres:postgres@localhost/botserver".to_string()),
max_connections: 10,
},
drive: DriveConfig::default(),
email: EmailConfig::default(),
site_path: std::env::var("SITE_PATH")
.unwrap_or_else(|_| "/opt/gbo/data".to_string()),
data_dir: std::env::var("DATA_DIR")
.unwrap_or_else(|_| "/opt/gbo/data".to_string()),
})
}
}
/// Configuration manager for runtime config updates
@ -237,14 +262,19 @@ impl Default for DriveConfig {
}
}
// Fallback to empty/localhost
// Fallback for development: read from environment or use minimal defaults
Self {
endpoint: "http://localhost:9100".to_string(),
bucket: String::new(),
endpoint: std::env::var("MINIO_ENDPOINT")
.unwrap_or_else(|_| "http://localhost:9100".to_string()),
bucket: std::env::var("MINIO_BUCKET")
.unwrap_or_else(|_| "default.gbai".to_string()),
region: "auto".to_string(),
access_key: String::new(),
secret_key: String::new(),
server: "localhost:9100".to_string(),
access_key: std::env::var("MINIO_ACCESS_KEY")
.unwrap_or_else(|_| "minioadmin".to_string()),
secret_key: std::env::var("MINIO_SECRET_KEY")
.unwrap_or_else(|_| "minioadmin".to_string()),
server: std::env::var("MINIO_SERVER")
.unwrap_or_else(|_| "localhost:9100".to_string()),
}
}
}