-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·59 lines (48 loc) · 1.5 KB
/
start.sh
File metadata and controls
executable file
·59 lines (48 loc) · 1.5 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
#!/bin/bash
# ClassPulse Startup Script
# This script sets up the environment and starts the ClassPulse application
set -e # Exit on any error
# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Configuration
VENV_DIR="$SCRIPT_DIR/venv"
PYTHON_BIN="$VENV_DIR/bin/python"
PIP_BIN="$VENV_DIR/bin/pip"
# Create virtual environment if it doesn't exist
if [ ! -d "$VENV_DIR" ]; then
echo "Creating virtual environment..."
python3 -m venv "$VENV_DIR"
fi
# Activate virtual environment
source "$VENV_DIR/bin/activate"
# Upgrade pip
echo "Upgrading pip..."
"$PIP_BIN" install --upgrade pip
# Install dependencies from requirements.txt
if [ -f "requirements.txt" ]; then
echo "Installing dependencies from requirements.txt..."
"$PIP_BIN" install -r requirements.txt
else
echo "Installing dependencies from pyproject.toml..."
"$PIP_BIN" install -e ".[prod]"
# Also install any missing dependencies
"$PIP_BIN" install requests cryptography
fi
# Create instance directory if it doesn't exist
mkdir -p instance
# Set environment variables for production
export FLASK_APP=app.py
export FLASK_ENV=production
# Start the application using gunicorn for production
echo "Starting ClassPulse application..."
exec "$VENV_DIR/bin/gunicorn" \
--bind 0.0.0.0:5000 \
--workers 4 \
--worker-class gthread \
--threads 2 \
--timeout 30 \
--keep-alive 2 \
--max-requests 1000 \
--max-requests-jitter 50 \
app:app