This repository was archived by the owner on Jul 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·73 lines (62 loc) · 1.84 KB
/
run.sh
File metadata and controls
executable file
·73 lines (62 loc) · 1.84 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
#!/bin/bash
# Make sure 'python' alias makes reference to Python 3.9 or highest version
# Also make sure to register the application inside CERN Application Portal
# and configure all the environment variables required
CMD=$1
if [[ $CMD != "dev" && $CMD != "prod" && $CMD != "test" && $CMD != "lint" ]]; then
echo "Please set a valid option - Options available: dev | prod | test | lint"
echo "Option provided: $CMD"
exit 1
fi
echo "Running '$CMD' command"
# Check if the virtual environment exists
echo "Checking if the virtual environment has been created"
VENV="$(pwd)/venv"
if [ ! -d "$VENV" ]; then
echo "Virtual environment does not exist, creating it"
python -m venv $VENV
source "$VENV/bin/activate"
pip install -r requirements.txt
echo "Virtual environment created successfully"
fi
echo "Activating the virtual environment"
source "$VENV/bin/activate"
if [ "$CMD" = "dev" ]; then
trap "exit" INT TERM ERR
trap "kill 0" EXIT
echo "Starting DEV python server"
python3 main.py &
python_pid=$!
echo "Starting DEV node server"
cd react_frontend/
yarn install
yarn start &
npm_pid=$!
cd ..
echo "python pid $python_pid"
echo "npm pid $npm_pid"
wait
fi
if [ "$CMD" = "prod" ]; then
BUNDLE="$(pwd)/build"
if [ ! -d "$BUNDLE" ]; then
echo "Web page bundle not found, creating it ..."
CURRENT_DIR=$(pwd)
cd react_frontend/
yarn install
yarn build
mv build/ ../
cd $CURRENT_DIR
fi
echo "Starting web page"
gunicorn main:app
fi
if [ "$CMD" = "test" ]; then
DATABASE_NAME=test_valdb python -m unittest
fi
if [ "$CMD" = "lint" ]; then
pylint `find . -type f | grep .py$ | grep -v env | grep -v tests/ | xargs` --disable=E0401,R0201,R0903,W0622 &&
cd react_frontend &&
yarn eslint &&
yarn tslint
fi