-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstop_all.sh
executable file
·62 lines (48 loc) · 1.52 KB
/
stop_all.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
#!/bin/bash
SERVER_PORT="$1"
if [ -z "$SERVER_PORT" ]; then
echo "SERVER PORT parameter is not defined. execute with port number"
exit 1
fi
CONDA_ENVIRONMENT="$2"
if [ -z "$CONDA_ENVIRONMENT" ]; then
CONDA_ENVIRONMENT="python38-MtblsWS"
echo "CONDA_ENVIRONMENT is not defined. $CONDA_ENVIRONMENT conda environment will be used."
fi
if [ -z "$CONFIG_FILE_PATH" ]; then
CONFIG_FILE_PATH="$APPDIR/config.yaml"
fi
if [ -z "$SECRETS_PATH" ]; then
SECRETS_PATH="$APPDIR/.secrets"
fi
HOST=$(hostname)
APPDIR=$(pwd -P)
LOG_PATH=$APPDIR/logs
cd $APPDIR
PROCESS_ID=$(ps -ef | grep "$LOG_PATH/gunicorn_${HOST}_${SERVER_PORT}" | grep -v "grep" | awk '{ print $2 }' | tr '\n' ' ')
if [ -z "$PROCESS_ID" ]; then
echo "NO GUNICORN SERVER"
else
echo "GUNICORN SERVER PROCESS_ID: ${PROCESS_ID} will be killed"
kill -9 $PROCESS_ID
fi
PROCESS_ID=$(ps -aux | grep "$LOG_PATH/celery_beat_${HOST}_${SERVER_PORT}.log" | grep -v "grep" | awk '{ print $2 }' | tr '\n' ' ')
if [ -z "$PROCESS_ID" ]; then
echo "NO CELERY BEAT"
else
echo "CELERY BEAT PROCESS_ID: ${PROCESS_ID} will be killed"
kill -9 $PROCESS_ID || echo "Process was not running."
fi
eval "$(conda shell.bash hook)"
conda activate $CONDA_ENVIRONMENT
source .env
export $(cat .env | grep -v '#' | xargs)
echo "Shutdown signal will be sent to all workers"
export C_FAKEFORK=1
celery -A app.tasks.worker:celery control shutdown
if [ $? -eq 0 ]; then
echo "Shutdown signal was sent to all workers"
else
echo "Shutdown signal task failed."
exit 1
fi