2025-10-06 10:30:17 -03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
|
|
# Define container limits in an associative array
|
|
|
|
|
declare -A container_limits=(
|
|
|
|
|
# Pattern Memory CPU Allowance
|
|
|
|
|
["*tables*"]="4096MB:100ms/100ms"
|
2026-01-25 21:21:22 -03:00
|
|
|
["*postgre*"]="4096MB:100ms/100ms" # PostgreSQL alternative
|
2025-10-06 10:30:17 -03:00
|
|
|
["*dns*"]="2048MB:100ms/100ms"
|
2026-01-27 13:45:54 -03:00
|
|
|
["*oppbot*"]="4048MB:100ms/100ms"
|
|
|
|
|
["*table-editor*"]="2048MB:25ms/100ms"
|
2025-10-06 10:30:17 -03:00
|
|
|
["*proxy*"]="2048MB:100ms/100ms"
|
|
|
|
|
["*directory*"]="1024MB:50ms/100ms"
|
feat: add ON EMAIL and ON CHANGE keywords for event-driven monitoring
- Add ON EMAIL keyword with FROM/SUBJECT filters
- Add ON CHANGE keyword with account:// syntax (gdrive, onedrive, dropbox, local)
- Add TriggerKind::EmailReceived (5) and FolderChange (6)
- Add migration 6.1.3_bot_hierarchy_monitors with:
- email_monitors, folder_monitors tables
- email_received_events, folder_change_events tables
- user_organizations table
- Bot hierarchy: parent_bot_id, enabled_tabs_json, inherit_parent_config
- Add 26 unit tests (12 on_email, 12 on_change, 2 trigger_kind)
- Update PROMPT.md with weekly maintenance checklist
- Zero warnings, zero errors
2025-12-18 16:17:58 -03:00
|
|
|
["*drive*"]="4096MB:100ms/100ms"
|
2026-01-25 21:21:22 -03:00
|
|
|
["*minio*"]="4096MB:100ms/100ms" # MinIO alternative
|
2025-10-06 10:30:17 -03:00
|
|
|
["*email*"]="4096MB:100ms/100ms"
|
2026-01-28 16:58:14 -03:00
|
|
|
["*webmail*"]="4096MB:100ms/100ms"
|
2026-01-27 13:45:54 -03:00
|
|
|
["*bot*"]="2048MB:25ms/100ms"
|
2026-01-28 16:58:14 -03:00
|
|
|
["*oppbot*"]="4096MB:50ms/100ms"
|
2025-10-06 10:30:17 -03:00
|
|
|
["*meeting*"]="4096MB:100ms/100ms"
|
2026-01-28 16:58:14 -03:00
|
|
|
["*alm*"]="2048MB:50ms/100ms"
|
|
|
|
|
["*vault*"]="2048MB:50ms/100ms"
|
2026-01-25 21:21:22 -03:00
|
|
|
["*alm-ci*"]="8192MB:200ms/100ms" # CHANGED: 100ms → 200ms (HIGHEST PRIORITY)
|
2025-10-06 10:30:17 -03:00
|
|
|
["*system*"]="4096MB:50ms/100ms"
|
2026-01-25 21:21:22 -03:00
|
|
|
["*mailer*"]="2096MB:25ms/100ms"
|
2025-10-06 10:30:17 -03:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Default values (for containers that don't match any pattern)
|
2026-01-28 16:58:14 -03:00
|
|
|
DEFAULT_MEMORY="2048MB"
|
2025-10-06 10:30:17 -03:00
|
|
|
DEFAULT_CPU_ALLOWANCE="15ms/100ms"
|
2026-01-25 21:21:22 -03:00
|
|
|
DEFAULT_CPU_COUNT=1
|
2025-10-06 10:30:17 -03:00
|
|
|
|
2026-01-25 21:21:22 -03:00
|
|
|
# PRIORITY LEVELS (1-10, where 10 is highest)
|
|
|
|
|
declare -A container_priority=(
|
|
|
|
|
["*alm-ci*"]="10" # HIGHEST PRIORITY - all sources for alm-ci
|
|
|
|
|
["*tables*"]="9" # High priority - PostgreSQL
|
|
|
|
|
["*postgre*"]="9" # High priority - PostgreSQL alternative
|
|
|
|
|
["*drive*"]="8" # High priority - MinIO
|
|
|
|
|
["*minio*"]="8" # High priority - MinIO alternative
|
|
|
|
|
["*directory*"]="7" # Medium priority - Zitadel
|
|
|
|
|
["*dns*"]="5" # Normal priority
|
|
|
|
|
["*proxy*"]="5" # Normal priority
|
|
|
|
|
["*email*"]="5" # Normal priority
|
|
|
|
|
["*webmail*"]="5" # Normal priority
|
|
|
|
|
["*meeting*"]="5" # Normal priority
|
|
|
|
|
["*system*"]="5" # Normal priority
|
|
|
|
|
["*bot*"]="4" # Lower priority
|
|
|
|
|
["*doc-editor*"]="4" # Lower priority
|
|
|
|
|
["*alm*"]="4" # Lower priority
|
|
|
|
|
["*mailer*"]="3" # Lowest priority
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Get all containers once
|
|
|
|
|
containers=$(lxc list -c n --format csv)
|
2025-10-06 10:30:17 -03:00
|
|
|
|
2026-01-25 21:21:22 -03:00
|
|
|
echo "Starting container configuration with priority levels..."
|
|
|
|
|
echo "========================================================="
|
|
|
|
|
|
|
|
|
|
# Configure all containers
|
|
|
|
|
for container in $containers; do
|
|
|
|
|
echo "Configuring $container..."
|
2026-01-27 13:45:54 -03:00
|
|
|
|
2025-10-06 10:30:17 -03:00
|
|
|
memory=$DEFAULT_MEMORY
|
|
|
|
|
cpu_allowance=$DEFAULT_CPU_ALLOWANCE
|
2026-01-25 21:21:22 -03:00
|
|
|
cpu_count=$DEFAULT_CPU_COUNT
|
|
|
|
|
cpu_priority=5 # Default priority if not specified
|
2025-10-06 10:30:17 -03:00
|
|
|
|
|
|
|
|
# Check if container matches any pattern
|
2026-01-25 21:21:22 -03:00
|
|
|
matched_pattern=""
|
|
|
|
|
for pattern in "${!container_limits[@]}"; do
|
|
|
|
|
# Convert pattern to regex: *tables* -> .*tables.*
|
|
|
|
|
regex_pattern="${pattern//\*/.*}"
|
|
|
|
|
if [[ $container =~ $regex_pattern ]]; then
|
2025-10-06 10:30:17 -03:00
|
|
|
IFS=':' read -r memory cpu_allowance <<< "${container_limits[$pattern]}"
|
2026-01-25 21:21:22 -03:00
|
|
|
matched_pattern=$pattern
|
|
|
|
|
echo " → Matched pattern: $pattern"
|
2026-01-27 13:45:54 -03:00
|
|
|
|
2026-01-25 21:21:22 -03:00
|
|
|
# Set CPU count based on service type
|
|
|
|
|
if [[ $pattern == "*alm-ci*" ]]; then
|
|
|
|
|
cpu_count=2 # More CPUs for alm-ci
|
|
|
|
|
elif [[ $pattern == "*tables*" ]] || [[ $pattern == "*postgre*" ]]; then
|
|
|
|
|
cpu_count=1 # More CPUs for PostgreSQL
|
|
|
|
|
elif [[ $pattern == "*drive*" ]] || [[ $pattern == "*minio*" ]]; then
|
|
|
|
|
cpu_count=1 # More CPUs for MinIO
|
2026-01-27 13:45:54 -03:00
|
|
|
else
|
2026-01-25 21:21:22 -03:00
|
|
|
cpu_count=1
|
|
|
|
|
fi
|
2025-10-06 10:30:17 -03:00
|
|
|
break
|
|
|
|
|
fi
|
|
|
|
|
done
|
2026-01-25 21:21:22 -03:00
|
|
|
|
|
|
|
|
# Set CPU priority if defined for this pattern
|
|
|
|
|
if [ -n "$matched_pattern" ] && [ -n "${container_priority[$matched_pattern]}" ]; then
|
|
|
|
|
cpu_priority="${container_priority[$matched_pattern]}"
|
|
|
|
|
else
|
|
|
|
|
# Set priority for all other containers (balanced for 10 users)
|
|
|
|
|
cpu_priority=5
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Apply configuration
|
|
|
|
|
echo " → Memory: $memory"
|
|
|
|
|
echo " → CPU: $cpu_count cores"
|
|
|
|
|
echo " → CPU Allowance: $cpu_allowance"
|
|
|
|
|
echo " → CPU Priority: $cpu_priority/10"
|
2026-01-27 13:45:54 -03:00
|
|
|
|
2026-01-25 21:21:22 -03:00
|
|
|
lxc config set "$container" limits.memory "$memory"
|
|
|
|
|
lxc config set "$container" limits.cpu.allowance "$cpu_allowance"
|
|
|
|
|
lxc config set "$container" limits.cpu "$cpu_count"
|
|
|
|
|
lxc config set "$container" limits.cpu.priority "$cpu_priority"
|
|
|
|
|
|
|
|
|
|
echo " → Restarting $container..."
|
|
|
|
|
lxc restart "$container" --timeout=30
|
2026-01-27 13:45:54 -03:00
|
|
|
|
2026-01-25 21:21:22 -03:00
|
|
|
echo " → Current config:"
|
|
|
|
|
lxc config show "$container" | grep -E "memory|cpu" | sed 's/^/ /'
|
|
|
|
|
echo ""
|
2025-10-06 10:30:17 -03:00
|
|
|
done
|
2026-01-25 21:21:22 -03:00
|
|
|
|
|
|
|
|
echo "========================================================="
|
|
|
|
|
echo "Configuration complete!"
|
|
|
|
|
echo ""
|
|
|
|
|
echo "PRIORITY SUMMARY:"
|
|
|
|
|
echo "1. alm-ci (build-run) → Priority 10/10, 200ms/100ms, 8GB RAM, 4 CPUs"
|
|
|
|
|
echo "2. tables/postgre → Priority 9/10, 100ms/100ms, 4GB RAM, 4 CPUs"
|
|
|
|
|
echo "3. drive/minio → Priority 8/10, 100ms/100ms, 4GB RAM, 3 CPUs"
|
|
|
|
|
echo "4. directory → Priority 7/10, 50ms/100ms, 1GB RAM, 2 CPUs"
|
|
|
|
|
echo "5. All others → Priority 5/10, default values (balanced for 10 users)"
|
2026-01-27 13:45:54 -03:00
|
|
|
echo "========================================================="
|