Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstorageServerScript.sh
More file actions
Latest commit
50 lines (41 loc) · 1.6 KB
/
Copy pathstorageServerScript.sh
File metadata and controls
50 lines (41 loc) · 1.6 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
#!/bin/bash
# Load environment variables
source /home/avinash/.bashrc
# ========== Configuration ==========
REPO_URL="https://github.com/ProjectIndra/storageServer.git"
APP_DIR="/home/avinash/servers/storageServer"
APP_PORT=2000
LOG_FILE="/home/avinash/storage_server.log"
# ===================================
# Kill any existing process using the port
echo"[*] Checking for processes using port $APP_PORT..."
PID=$(lsof -t -i:$APP_PORT)
if [ -n"$PID" ];then
echo"[*] Killing process $PID using port $APP_PORT"
kill -9 "$PID"
fi
# Clone or pull the repo
if [ !-d"$APP_DIR" ];then
echo"[*] Cloning repo..."
git clone "$REPO_URL""$APP_DIR"
else
echo"[*] Pulling latest changes..."
cd"$APP_DIR"||exit 1
git pull origin master
fi
cd"$APP_DIR"||exit 1
# Initialize Poetry if pyproject.toml or poetry.lock is not found
if [ !-f"pyproject.toml" ] && [ !-f"poetry.lock" ];then
echo"[*] pyproject.toml or poetry.lock not found, initializing Poetry..."
/home/avinash/.local/bin/poetry init --no-interaction
/home/avinash/.local/bin/poetry add flask
else
echo"[*] pyproject.toml or poetry.lock found, skipping Poetry initialization."
fi
# Install dependencies using Poetry
echo"[*] Installing dependencies using Poetry..."
/home/avinash/.local/bin/poetry install --no-root
# Run the Flask app using Poetry and log output
echo"[*] Starting Flask server on port $APP_PORT..."
/home/avinash/.local/bin/poetry run flask --app server.py run --host=0.0.0.0 --port=$APP_PORT>"$LOG_FILE"2>&1< /dev/null &
echo"[✅] Server started on port $APP_PORT, logging to $LOG_FILE"