This repository has been archived by the owner on Dec 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.bash
74 lines (61 loc) · 1.62 KB
/
start.bash
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
#!/bin/bash
# Enabling job control
set -m
echo "starting a Supervisor daemon"
supervisord &
sleep 5
restart_supervisor() {
echo "restarting a Supervisor daemon"
supervisorctl stop all || return $?
killall supervisord || return $?
supervisord &
sleep 5
}
# To update the repo contents
check_repo () {
REPO="$1"
BRANCH="$2"
LOCATION="$3"
echo "checking $REPO on branch $BRANCH of $LOCATION"
# Check if is the same repo
if cd "$LOCATION" && [ -f '.git' ] \
&& [ "$REPO" = "$(git remote get-url origin)" ]; then
echo "pulling repo"
git pull origin HEAD || return $?
else
echo "removing repo"
cd / && rm -rf $LOCATION || return $?
# Clone with or without specific branch
if [ -z "$BRANCH" ]; then
echo "cloning"
git clone "$REPO" "$LOCATION" || return $?
else
echo "cloning on $branch"
git clone -b "$BRANCH" "$REPO" "$LOCATION" || return $?
fi
fi
}
# Prepare the bot module
if [ ! -z "$BOT_REPO" ]; then
if check_repo "$BOT_REPO" "$BOT_REPO_BRANCH" /app/bot || exit $?; then
echo "installing bot dependencies"
cd /app/bot && yarn install || exit $?
fi
fi
# Prepare the NLU module
if [ -z "$NLU_URL" ]; then
export NLU_URL=http://localhost:6000
restart_supervisor || exit $?
if [ ! -z "$NLU_REPO" ]; then
if check_repo "$NLU_REPO" "$NLU_REPO_BRANCH" /app/nlu || exit $?; then
echo "training nlu model"
cd /app/nlu && rasa train || exit $?
fi
fi
echo "starting the nlu module"
supervisorctl start nlu || exit $?
fi
echo "starting the bot module"
supervisorctl stop redirector || exit $?
supervisorctl start bot || exit $?
fg