-
Notifications
You must be signed in to change notification settings - Fork 0
/
start-celery.sh
executable file
·71 lines (67 loc) · 1.31 KB
/
start-celery.sh
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
#!/bin/bash
VIRT_ENV="bin"
check_requirements(){
rc=0
echo "Checking neccesary constraints to run the project"
echo -ne "1. requirements.txt exists\t"
if [[ -r "requirements.txt" ]]
then
echo "OK"
else
echo "NO"
rc=1
fi
echo -ne "2. virtual env exists\t"
if [[ -r "$VIRT_ENV/bin/activate" ]]
then
echo "OK"
else
echo "NO, setting up"
if ! python -m venv "$VIRT_ENV"
then
echo "Unable to set up virtual env"
rc=1
fi
fi
echo -ne "3. .env exists\t"
if [[ -r ".env" ]]
then
echo "OK"
else
if [[ -r ".env.demo" ]]
then
echo "NO, copying .env.demo to .env"
cp .env.demo .env
echo "SECRET_KEY=$(date +%s%N | sha512sum | cut -d' ' -f1)" >> .env
else
echo "NO, and neither does .env.demo"
rc=1
fi
fi
return "$rc"
}
if check_requirements
then
echo "All requirements satisfied"
else
echo "Requirements not satisfied"
exit 1
fi
echo "Using virtual env located at $VIRT_ENV"
if ! source "$VIRT_ENV/bin/activate"
then
echo "Error Occurred"
exit 1
fi
echo "Installing all requirements"
if ! pip install -qqr requirements.txt
then
echo "Error Occurred"
exit 1
fi
echo "Running celery worker"
if ! celery -A app.celery worker --loglevel=info
then
echo "Error Occurred"
exit 1
fi