mirror of
https://github.com/zvx-echo6/meshai.git
synced 2026-08-26 17:31:34 +00:00
refactor: move source tree into work/, multi-stage Docker build, fix satpass
- Move all application source (meshai/, dashboard-frontend/, tests/, config/, docs/, Dockerfile, etc.) into work/ directory - Add Node.js multi-stage build to Dockerfile for frontend compilation; remove compiled static assets from git tracking - Fix satpass missing time windows: consolidation was splitting wire on newline and only putting line 1 in event.title, dropping the time window line that the composer uses for precomposed broadcasts - Fix satpass burst flooding: stagger consolidation timers (+60s per pending pass) so Central batch publishes don't blast the mesh - Update CI workflow build context to work/ - Anchor lib/ and data/ gitignore patterns to repo root to prevent false matches on nested directories - Add dashboard-frontend/node_modules/ to .dockerignore Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
7128b432ee
commit
2e1fb325f7
283 changed files with 109402 additions and 483 deletions
129
work/docker-entrypoint.sh
Executable file
129
work/docker-entrypoint.sh
Executable file
|
|
@ -0,0 +1,129 @@
|
|||
#!/bin/bash
|
||||
# MeshAI Docker Entrypoint
|
||||
# Runs ttyd for web config access and the bot
|
||||
|
||||
export MESHAI_CONFIG="/data/config.yaml"
|
||||
export TERM="${TERM:-xterm-256color}"
|
||||
|
||||
# First run - no config exists, create defaults
|
||||
if [ ! -f "$MESHAI_CONFIG" ]; then
|
||||
mkdir -p /data
|
||||
cat > "$MESHAI_CONFIG" << 'EOF'
|
||||
# MeshAI Configuration
|
||||
# Configure via http://localhost:7682
|
||||
|
||||
bot:
|
||||
name: ai
|
||||
owner: ""
|
||||
respond_to_dms: true
|
||||
filter_bbs_protocols: true
|
||||
|
||||
connection:
|
||||
type: tcp
|
||||
serial_port: /dev/ttyUSB0
|
||||
tcp_host: localhost
|
||||
tcp_port: 4403
|
||||
|
||||
response:
|
||||
delay_min: 2.2
|
||||
delay_max: 3.0
|
||||
max_length: 150
|
||||
max_messages: 2
|
||||
|
||||
history:
|
||||
database: /data/conversations.db
|
||||
max_messages_per_user: 50
|
||||
conversation_timeout: 86400
|
||||
auto_cleanup: true
|
||||
cleanup_interval_hours: 24
|
||||
max_age_days: 30
|
||||
|
||||
memory:
|
||||
enabled: true
|
||||
window_size: 4
|
||||
summarize_threshold: 8
|
||||
|
||||
context:
|
||||
enabled: true
|
||||
observe_channels: []
|
||||
ignore_nodes: []
|
||||
max_age: 2592000
|
||||
max_context_items: 20
|
||||
|
||||
llm:
|
||||
backend: openai
|
||||
api_key: ""
|
||||
base_url: https://api.openai.com/v1
|
||||
model: gpt-4o-mini
|
||||
timeout: 30
|
||||
system_prompt: >-
|
||||
You are a helpful assistant on a Meshtastic mesh network.
|
||||
Keep responses VERY brief - under 250 characters total.
|
||||
Be concise but friendly. No markdown formatting.
|
||||
google_grounding: false
|
||||
|
||||
meshmonitor:
|
||||
enabled: false
|
||||
inject_into_prompt: true
|
||||
EOF
|
||||
echo "Default config created. Configure via http://localhost:7682"
|
||||
fi
|
||||
|
||||
|
||||
# Start ttyd for web-based config access
|
||||
echo "Starting web config interface on port 7682..."
|
||||
ttyd -W -p 7682 \
|
||||
-t enableClipboard=true \
|
||||
-t titleFixed="MeshAI Config" \
|
||||
-t 'theme={"background":"#0d1117","foreground":"#c9d1d9","cursor":"#58a6ff","selectionBackground":"#388bfd"}' \
|
||||
-t fontSize=14 \
|
||||
/bin/bash -c 'while true; do python3 -m meshai --config-file "$MESHAI_CONFIG" --config; sleep 1; done' &
|
||||
|
||||
# Keep ttyd running even if bot fails
|
||||
trap "kill %1 2>/dev/null" EXIT
|
||||
|
||||
# Kill bot gracefully with SIGKILL fallback
|
||||
kill_bot() {
|
||||
local pid=$1
|
||||
if ! kill -0 "$pid" 2>/dev/null; then
|
||||
return
|
||||
fi
|
||||
kill "$pid" 2>/dev/null || true
|
||||
echo "Sent SIGTERM to bot (PID $pid)"
|
||||
# Wait up to 5 seconds for graceful shutdown
|
||||
for i in 1 2 3 4 5; do
|
||||
kill -0 "$pid" 2>/dev/null || return
|
||||
sleep 1
|
||||
done
|
||||
# Force kill if still alive
|
||||
if kill -0 "$pid" 2>/dev/null; then
|
||||
kill -9 "$pid" 2>/dev/null || true
|
||||
echo "Sent SIGKILL to bot (PID $pid)"
|
||||
fi
|
||||
}
|
||||
|
||||
# Start the bot in a loop with integrated restart watcher
|
||||
echo "Starting MeshAI..."
|
||||
rm -f /tmp/meshai_restart
|
||||
while true; do
|
||||
python -m meshai -v --config-file "$MESHAI_CONFIG" &
|
||||
BOT_PID=$!
|
||||
echo "$BOT_PID" > /tmp/meshai.pid
|
||||
echo "Bot started (PID $BOT_PID)"
|
||||
|
||||
# Poll: wait for bot to exit OR restart signal
|
||||
while kill -0 $BOT_PID 2>/dev/null; do
|
||||
if [ -f /tmp/meshai_restart ]; then
|
||||
rm -f /tmp/meshai_restart
|
||||
echo "Restart signal received, restarting bot..."
|
||||
kill_bot $BOT_PID
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
wait $BOT_PID 2>/dev/null || true
|
||||
rm -f /tmp/meshai.pid
|
||||
echo "Bot exited. Restarting in 3s..."
|
||||
sleep 3
|
||||
done
|
||||
Loading…
Add table
Add a link
Reference in a new issue