-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
90 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/bin/bash | ||
|
||
#define the server and client directories | ||
SERVER="../server" | ||
FRONTEND="../frontend" | ||
|
||
#check if a port is available | ||
check_port() { | ||
PORT=$1 | ||
nc -z localhost $PORT | ||
if [ $? -eq 0 ]; then | ||
echo "Port $PORT is in use" | ||
exit 1 | ||
fi | ||
} | ||
|
||
#install dependencies and start the server | ||
start_server() { | ||
echo "Navigating to server directory: $SERVER" | ||
cd $SERVER || { echo "Server directory not found!"; exit 1;} | ||
|
||
echo "Installing dependencies..." | ||
npm install | ||
|
||
#check if port 3000 is available | ||
check_port 3000 | ||
|
||
|
||
|
||
echo "Starting server..." | ||
node server.js | ||
} | ||
|
||
#install dependencies and start the frontend | ||
start_frontend() { | ||
echo "Navigating to client directory: $FRONTEND" | ||
cd $FRONTEND || { echo "Frontend directory not found!"; exit 1; } | ||
|
||
echo "Installing dependencies..." | ||
npm install | ||
|
||
echo "Starting frontend..." | ||
|
||
TEST_PORT=3001 | ||
check_port TEST_PORT | ||
while [ $? -eq 1 ]; do | ||
TEST_PORT=$((TEST_PORT+1)) | ||
check_port TEST_PORT | ||
done | ||
PORT=TEST_PORT npm start | ||
} | ||
|
||
#run the server and frontend | ||
start_server & start_frontend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
#define frontend and server directories | ||
SERVER="../server" | ||
FRONTEND="../frontend" | ||
|
||
#start the server | ||
start_server() { | ||
echo "Navigating to server directory: $SERVER" | ||
cd $SERVER || { echo "Server directory not found!"; exit 1;} | ||
|
||
echo "Starting server..." | ||
node server.js | ||
} | ||
|
||
#start the frontend | ||
start_frontend() { | ||
echo "Navigating to client directory: $FRONTEND" | ||
cd $FRONTEND || { echo "Frontend directory not found!"; exit 1; } | ||
|
||
echo "Starting frontend..." | ||
PORT=3001 npm start | ||
} | ||
|
||
#run the server and frontend | ||
start_server & start_frontend |