forked from Tomobobo710/SimpleChatJS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
60 lines (54 loc) · 1.55 KB
/
Copy pathstart.sh
File metadata and controls
60 lines (54 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
60
#!/bin/bash
echo "[STARTING] SimpleChatJS"
echo "Chat will be available at: http://localhost:50505"
echo "Browser will open automatically."
echo ""
# Check if Node.js is installed
echo "Checking for Node.js installation..."
if ! command -v node >/dev/null 2>&1; then
echo ""
echo "[ERROR] Node.js is not installed!"
echo ""
echo "Please download and install Node.js from:"
echo "https://nodejs.org"
echo ""
echo "After installing, restart this script."
exit 1
fi
echo "Node.js found!"
echo ""
# Install dependencies if node_modules doesn't exist or is incomplete
if [ ! -d "node_modules" ]; then
echo "Installing dependencies..."
npm install
if [ $? -ne 0 ]; then
echo "Failed to install dependencies!"
exit 1
fi
echo "Dependencies installed successfully!"
else
echo "Checking if all dependencies are installed..."
npm ls --depth=0 >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Missing dependencies detected, installing..."
npm install
if [ $? -ne 0 ]; then
echo "Failed to install dependencies!"
exit 1
fi
echo "Dependencies installed successfully!"
else
echo "All dependencies are present."
fi
fi
# Kill any existing server on port 50505
echo "Checking for existing server on port 50505..."
PID=$(lsof -ti:50505 2>/dev/null)
if [ ! -z "$PID" ]; then
echo "Found process $PID using port 50505, killing it..."
kill -9 $PID 2>/dev/null
sleep 1
fi
# Start the server
echo "Starting server..."
node backend/server.js