Skip to content

Commit 7f3f152

Browse files
script added for crontab
1 parent 251585c commit 7f3f152

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

dashboard.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
# Change to the directory where your Flask app is located
4+
# cd /home/alphahub/development/SystemDashboard || { echo "Directory not found"; exit 1; }
5+
6+
# Create virtual environment if it doesn't exist; otherwise, activate it
7+
eval "$(conda shell.bash hook)"
8+
9+
# Check if the conda environment exists
10+
if ! conda env list | grep -q "systemdashboard"; then
11+
echo "Creating conda environment 'systemdashboard'"
12+
conda create -n systemdashboard python=3.10 -y
13+
echo "Activating conda environment 'systemdashboard'"
14+
conda activate systemdashboard
15+
echo "Installing required packages"
16+
pip install -r requirements.txt
17+
else
18+
echo "Activating existing conda environment 'systemdashboard'"
19+
conda activate systemdashboard
20+
fi
21+
22+
# Continue with the rest of your script
23+
echo "Conda environment 'systemdashboard' is active."
24+
25+
# Export Flask environment variables
26+
export FLASK_APP=app.py
27+
export FLASK_ENV=development # or production
28+
29+
# Check if Flask app is running
30+
if ! pgrep -f "flask run --host=0.0.0.0 --port=5050" > /dev/null; then
31+
echo "Flask app is not running. Starting..."
32+
flask run --host=0.0.0.0 --port=5050 &
33+
else
34+
echo "Flask app is already running."
35+
fi

0 commit comments

Comments
 (0)