-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
143 lines (115 loc) Β· 3.28 KB
/
Copy pathstart.sh
File metadata and controls
143 lines (115 loc) Β· 3.28 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/bash
# AudioSync Startup Script
echo "π΅ Starting AudioSync..."
echo "========================"
# Check if Python is installed
if ! command -v python3 &> /dev/null; then
echo "β Python 3 is not installed. Please install Python 3.8 or higher."
exit 1
fi
# Check if Node.js is installed
if ! command -v node &> /dev/null; then
echo "β Node.js is not installed. Please install Node.js 16 or higher."
exit 1
fi
# Function to start the Python server
start_server() {
echo "π Starting Python server..."
cd server
# Check if virtual environment exists
if [ ! -d "venv" ]; then
echo "π¦ Creating Python virtual environment..."
python3 -m venv venv
fi
# Activate virtual environment
source venv/bin/activate
# Install dependencies
echo "π¦ Installing Python dependencies..."
pip install -r requirements.txt
# Generate test audio files
echo "π΅ Generating test audio files..."
python test_audio.py
# Start the server
echo "π Starting AudioSync server..."
python main.py &
SERVER_PID=$!
cd ..
echo "β
Server started (PID: $SERVER_PID)"
return $SERVER_PID
}
# Function to start React Native
start_app() {
echo "π± Starting React Native app..."
# Install dependencies if node_modules doesn't exist
if [ ! -d "node_modules" ]; then
echo "π¦ Installing React Native dependencies..."
npm install
fi
# Start Metro bundler
echo "π Starting Metro bundler..."
npm start &
METRO_PID=$!
echo "β
Metro bundler started (PID: $METRO_PID)"
# Wait a moment for Metro to start
sleep 3
# Ask user which platform to run
echo ""
echo "π± Choose platform to run:"
echo "1) Android"
echo "2) iOS"
echo "3) Skip (run manually)"
read -p "Enter choice (1-3): " platform_choice
case $platform_choice in
1)
echo "π€ Starting Android app..."
npm run android &
;;
2)
echo "π Starting iOS app..."
npm run ios &
;;
3)
echo "βΉοΈ Run 'npm run android' or 'npm run ios' manually"
;;
*)
echo "βΉοΈ Invalid choice. Run 'npm run android' or 'npm run ios' manually"
;;
esac
}
# Function to cleanup processes
cleanup() {
echo ""
echo "π Stopping AudioSync..."
if [ ! -z "$SERVER_PID" ]; then
kill $SERVER_PID 2>/dev/null
echo "β
Server stopped"
fi
if [ ! -z "$METRO_PID" ]; then
kill $METRO_PID 2>/dev/null
echo "β
Metro bundler stopped"
fi
# Kill any remaining processes
pkill -f "python.*main.py" 2>/dev/null
pkill -f "node.*metro" 2>/dev/null
echo "π AudioSync stopped"
exit 0
}
# Set up signal handlers
trap cleanup SIGINT SIGTERM
# Main execution
echo "π§ Setting up AudioSync..."
# Start server
start_server
SERVER_PID=$?
# Start app
start_app
echo ""
echo "π AudioSync is running!"
echo "π± Mobile app: Connect to ws://$(hostname -I | awk '{print $1}'):8080"
echo "π Server: http://localhost:8080"
echo ""
echo "Press Ctrl+C to stop all services"
# Wait for user interrupt
while true; do
sleep 1
done