-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-all.sh
More file actions
121 lines (98 loc) · 2.86 KB
/
Copy pathstart-all.sh
File metadata and controls
121 lines (98 loc) · 2.86 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
#!/bin/bash
# AddressBook Full-Stack Application Startup Script
echo "🚀 Starting AddressBook Full-Stack Application..."
# Function to check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Check prerequisites
echo "📋 Checking prerequisites..."
if ! command_exists node; then
echo "❌ Node.js is not installed. Please install Node.js v14 or higher."
exit 1
fi
if ! command_exists npm; then
echo "❌ npm is not installed. Please install npm."
exit 1
fi
if ! command_exists mysql; then
echo "⚠️ MySQL command not found. Make sure MySQL is installed and running."
fi
echo "✅ Prerequisites check completed."
# Install dependencies if node_modules don't exist
echo "📦 Installing dependencies..."
# Backend dependencies
if [ ! -d "backend/node_modules" ]; then
echo "Installing backend dependencies..."
cd backend && npm install && cd ..
fi
# User App dependencies
if [ ! -d "frontend/user-app/node_modules" ]; then
echo "Installing user app dependencies..."
cd frontend/user-app && npm install && cd ../..
fi
# Admin App dependencies
if [ ! -d "frontend/admin-app/node_modules" ]; then
echo "Installing admin app dependencies..."
cd frontend/admin-app && npm install && cd ../..
fi
echo "✅ Dependencies installed."
# Check if .env file exists
if [ ! -f "backend/.env" ]; then
echo "⚠️ .env file not found. Copying from .env.example..."
cp backend/.env.example backend/.env
echo "📝 Please edit backend/.env with your database credentials before starting the servers."
echo "Press any key to continue..."
read -n 1 -s
fi
# Start all services
echo "🚀 Starting all services..."
# Start backend server
echo "Starting backend server on port 5000..."
cd backend
npm run dev &
BACKEND_PID=$!
cd ..
# Wait a moment for backend to start
sleep 3
# Start user app
echo "Starting user app on port 3000..."
cd frontend/user-app
BROWSER=none npm start &
USER_APP_PID=$!
cd ../..
# Wait a moment
sleep 2
# Start admin app
echo "Starting admin app on port 3001..."
cd frontend/admin-app
BROWSER=none PORT=3001 npm start &
ADMIN_APP_PID=$!
cd ../..
echo ""
echo "🎉 All services started successfully!"
echo ""
echo "📱 Access your applications:"
echo " 👤 User App: http://localhost:3000"
echo " 🔧 Admin App: http://localhost:3001"
echo " 🔌 API Server: http://localhost:5000"
echo ""
echo "🔑 Default admin credentials:"
echo " Username: admin"
echo " Password: admin123"
echo ""
echo "Press Ctrl+C to stop all services..."
# Function to cleanup on exit
cleanup() {
echo ""
echo "🛑 Stopping all services..."
kill $BACKEND_PID 2>/dev/null
kill $USER_APP_PID 2>/dev/null
kill $ADMIN_APP_PID 2>/dev/null
echo "✅ All services stopped."
exit 0
}
# Set trap to cleanup on script exit
trap cleanup SIGINT SIGTERM
# Wait for user to stop the script
wait