forked from AsmiBhaskar/Voltonic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrestart-backend.sh
More file actions
executable file
·73 lines (64 loc) · 2.04 KB
/
Copy pathrestart-backend.sh
File metadata and controls
executable file
·73 lines (64 loc) · 2.04 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
# Voltonic Full Restart Script
# This script completely restarts the backend with fresh data
echo "🔄 Restarting Voltonic Energy Management System..."
echo ""
# Step 1: Kill existing Flask process
echo "1️⃣ Killing existing Flask server on port 5000..."
lsof -ti:5000 | xargs kill -9 2>/dev/null
echo " ✓ Port 5000 freed"
echo ""
# Step 2: Delete old database
echo "2️⃣ Removing old database..."
rm -f instance/voltonic.db
echo " ✓ Database deleted"
echo ""
# Step 3: Start Flask server in background
echo "3️⃣ Starting Flask server..."
echo " This will seed the database with:"
echo " - 3 Energy sources (Grid, Solar, Diesel)"
echo " - 4 Faculties"
echo " - 12 Buildings"
echo " - 36 Floors"
echo " - 1,296 Rooms (Classrooms, Labs, Staff, Smart_Class)"
echo ""
python run.py &
FLASK_PID=$!
echo " ✓ Flask server started (PID: $FLASK_PID)"
echo ""
# Step 4: Wait for server to be ready
echo "4️⃣ Waiting for server to initialize..."
sleep 5
# Step 5: Check health
echo "5️⃣ Checking server health..."
HEALTH=$(curl -s http://127.0.0.1:5000/api/health)
if [ $? -eq 0 ]; then
echo " ✓ Server is healthy!"
echo ""
echo "📊 Server Status:"
echo "$HEALTH" | python -m json.tool 2>/dev/null || echo "$HEALTH"
else
echo " ⚠️ Server not responding yet, please wait..."
fi
echo ""
echo "✅ Backend is running!"
echo ""
echo "📌 Next Steps:"
echo " 1. In a new terminal, start the dashboard:"
echo " cd dashboard && npm start"
echo ""
echo " 2. Open browser to: http://localhost:3000"
echo ""
echo " 3. Try the new features:"
echo " - Energy Flow tab (visual energy flow diagram)"
echo " - Management tab (add rooms, floors, buildings)"
echo ""
echo "💡 To simulate a power outage:"
echo " curl -X POST http://127.0.0.1:5000/api/grid-status \\"
echo " -H 'Content-Type: application/json' \\"
echo " -d '{\"grid_available\": false, \"reason\": \"Testing\"}'"
echo ""
echo "Press Ctrl+C to stop the Flask server"
echo ""
# Keep script running
wait $FLASK_PID