-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstart-workers
More file actions
48 lines (40 loc) · 1.32 KB
/
start-workers
File metadata and controls
48 lines (40 loc) · 1.32 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
#!/bin/bash
# ----------------------------------
# Colors
# ----------------------------------
NOCOLOR='\033[0m'
RED='\033[0;31m'
GREEN='\033[0;32m'
ORANGE='\033[0;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
LIGHTGRAY='\033[0;37m'
DARKGRAY='\033[1;30m'
LIGHTRED='\033[1;31m'
LIGHTGREEN='\033[1;32m'
YELLOW='\033[1;33m'
LIGHTBLUE='\033[1;34m'
LIGHTPURPLE='\033[1;35m'
LIGHTCYAN='\033[1;36m'
WHITE='\033[1;37m'
# Handling for Git Bash for Windows
# (incl. workaround for https://github.com/yarnpkg/yarn/issues/2591)
case "$(uname -s)" in
MINGW*)
export FORCE_COLOR=true
yarn=yarn.cmd
;;
*) yarn=yarn;;
esac
# ----------------------------------
# Set default options
CPU_COUNT=$(grep -c ^processor /proc/cpuinfo)
# There must be at least two threads running to process any sub-derivations.
NUM_PROCESSES=${NUM_PROCESSES:-$CPU_COUNT}
NUM_THREADS=${NUM_THREADS:-4}
TASK_MODULES=${TASK_MODULES:-django_dramatiq.setup django_dramatiq.tasks grammar.tasks}
DJANGO_SETTINGS_MODULE=${DJANGO_SETTINGS_MODULE:-app.settings}
DRAMATIQ_PATH=${DRAMATIQ_PATH:-./packages/django-backend}
echo -e "${CYAN}Starting Python task workers (Dramatiq)...${NOCOLOR}"
DJANGO_SETTINGS_MODULE=${DJANGO_SETTINGS_MODULE} poetry run dramatiq --path ${DRAMATIQ_PATH} --processes ${NUM_PROCESSES} --threads ${NUM_THREADS} ${TASK_MODULES}