Setup fix

This commit is contained in:
Aodhan Collins
2025-07-27 01:36:41 +01:00
parent 6319df7d29
commit ecb0e2b81d

View File

@@ -59,17 +59,32 @@ check_docker() {
install_dependencies() {
print_status "Installing Python dependencies..."
# Detect Python environment
PYTHON_CMD="python3"
PIP_CMD="pip3"
# Check if we're in a virtual environment
if [[ -n "$VIRTUAL_ENV" ]]; then
print_status "Detected virtual environment: $VIRTUAL_ENV"
PIP_CMD="pip"
elif [[ -f "venv/bin/activate" ]]; then
print_status "Detected local virtual environment"
source venv/bin/activate
PIP_CMD="pip"
fi
# Check if pip is available
if ! command -v pip3 &> /dev/null; then
print_error "pip3 is not installed. Please install pip3 first"
if ! command -v $PIP_CMD &> /dev/null; then
print_error "pip is not available. Please install pip first"
exit 1
fi
# Install requirements
# Install requirements with appropriate flags
if [[ -f "requirements.txt" ]]; then
pip3 install -r requirements.txt
$PIP_CMD install -r requirements.txt --break-system-packages || $PIP_CMD install -r requirements.txt
else
pip3 install flask flask-cors docker requests python-dotenv
$PIP_CMD install flask flask-cors docker requests python-dotenv --break-system-packages || \
$PIP_CMD install flask flask-cors docker requests python-dotenv
fi
print_status "Dependencies installed successfully"
@@ -101,9 +116,20 @@ setup_environment() {
initialize_database() {
print_status "Initializing database..."
# Detect Python command
PYTHON_CMD="python3"
if [[ -n "$VIRTUAL_ENV" ]] || [[ -f "venv/bin/activate" ]]; then
if [[ -f "venv/bin/activate" ]]; then
source venv/bin/activate
PYTHON_CMD="python"
else
PYTHON_CMD="python"
fi
fi
# Create database if it doesn't exist
if [[ ! -f "dashboard.db" ]]; then
python3 -c "
$PYTHON_CMD -c "
import database
db = database.DatabaseManager()
db.init_db()
@@ -132,11 +158,22 @@ kill_existing_processes() {
launch_application() {
print_status "Launching Docker Dashboard..."
# Detect Python command
PYTHON_CMD="python3"
if [[ -n "$VIRTUAL_ENV" ]] || [[ -f "venv/bin/activate" ]]; then
if [[ -f "venv/bin/activate" ]]; then
source venv/bin/activate
PYTHON_CMD="python"
else
PYTHON_CMD="python"
fi
fi
# Create logs directory
mkdir -p logs
# Launch the application in background
nohup python3 api.py > logs/dashboard.log 2>&1 &
nohup $PYTHON_CMD api.py > logs/dashboard.log 2>&1 &
# Get the process ID
APP_PID=$!