-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstart_app.sh
More file actions
executable file
·94 lines (76 loc) · 2.19 KB
/
start_app.sh
File metadata and controls
executable file
·94 lines (76 loc) · 2.19 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
# To run the script, execute the following commands:
# chmod +x start_app.sh && ./start_app.sh
# Function to check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Trap EXIT signal to kill all background processes
trap 'kill $(jobs -p)' EXIT
# Check and install Homebrew (for macOS)
if [[ "$OSTYPE" == "darwin"* ]]; then
if ! command_exists brew; then
echo "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
# Install libomp
if ! brew list libomp &>/dev/null; then
echo "Installing libomp..."
brew install libomp
fi
fi
# Check and install Redis
if ! command_exists redis-server; then
echo "Redis not found. Installing Redis..."
if [[ "$OSTYPE" == "darwin"* ]]; then
brew install redis
elif command_exists apt-get; then
sudo apt-get update
sudo apt-get install -y redis-server
else
echo "Unsupported OS for automatic Redis installation. Please install Redis manually."
exit 1
fi
fi
# Start Redis server in the background
redis-server &
# Start the client
cd client
# check if node_modules are up to date with package.json
if ! cmp --silent package.json <(cat package.json); then
echo "Installing dependencies..."
npm i
else
echo "Dependencies are up to date."
fi
echo "Starting client..."
npm start &
# Start the server
cd ../server
if [ -d "venv" ]; then
echo "Virtual environment exists."
else
echo "Creating virtual environment..."
python3 -m venv venv
fi
# Activate virtual environment
source venv/bin/activate
# Compare pip freeze to requirements.txt
if ! cmp --silent requirements.txt <(pip freeze); then
#clear all installed packages
pip freeze | xargs pip uninstall -y
echo "Installing dependencies..."
pip install -r requirements.txt
else
echo "Dependencies are up to date."
fi
python app.py &
# Check and install Celery
if ! command_exists celery; then
echo "Celery not found. Installing Celery..."
pip install celery
fi
# Start Celery worker
celery -A tasks.celery worker --loglevel=info &
# Wait for all background processes
wait