Repository navigation
Expand file tree
/
Copy pathstart_production.sh
More file actions
59 lines (48 loc) · 1.55 KB
/
Copy pathstart_production.sh
File metadata and controls
59 lines (48 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
# Production startup script for Raspberry Pi 4
# This script starts the temperature monitor service using Waitress
# for production-grade deployment.
set -e
export PRODUCTION_MODE=true
# Check if running on Raspberry Pi
if [ -f /proc/device-tree/model ]; then
MODEL=$(cat /proc/device-tree/model)
echo "Running on: $MODEL"
fi
# Get script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Check if virtual environment exists
if [ ! -d "venv" ]; then
echo "Error: Virtual environment not found at ./venv"
echo "Please create one with: python3 -m venv venv && source venv/bin/activate && pip install -r requirements.txt"
exit 1
fi
# Activate virtual environment
echo "Activating virtual environment..."
source venv/bin/activate
# Verify required modules are installed
echo "Checking dependencies..."
python -c "import waitress, psutil, flask" || {
echo "Error: Required packages not installed"
echo "Run: pip install -r requirements.txt"
exit 1
}
# Create logs directory if it doesn't exist
mkdir -p logs
echo "Starting Temperature Monitor in production mode..."
echo "Server will be available at http://localhost:8080"
echo "Health endpoint: http://localhost:8080/health"
echo "Metrics endpoint: http://localhost:8080/metrics"
echo "API documentation: http://localhost:8080/docs"
echo ""
echo "Press Ctrl+C to stop"
echo ""
# Start server with Waitress
waitress-serve \
--host=0.0.0.0 \
--port=8080 \
--threads=1 \
--channel-timeout=120 \
--connection-limit=50 \
wsgi:app