-
Notifications
You must be signed in to change notification settings - Fork 11
/
start.sh
executable file
·52 lines (44 loc) · 1.46 KB
/
start.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
#!/bin/bash
set -e
rebuild () {
echo "Compiling typescript..."
npx tsc
}
RUN_ID=$(openssl rand -hex 12)
if [ "${MINIMAL_RUN}" != "true" ]; then
echo "Bootstrapping..."
if [ "${NODE_ENV}" == "production" ]; then
npx ts-node src/seed/bootstrap.ts
else
npx ts-node --swc src/seed/bootstrap.ts
fi
fi
# run with ts-node + swc, no transpile needed
if [ "${NODE_ENV}" == "development_ts_node" ]; then
cd src/
exec env RUN_ID=$RUN_ID npx ts-node --swc kmq.ts
fi
# transpile project
if [[ $1 == 'native' ]]
then
echo "Killing running instances..."
ps x | grep node | grep "${PWD}/" | grep -E "kmq\.js|cluster_manager\.js|kmq\.ts" | awk '{print $1}' | xargs kill &> /dev/null || echo "No running instances to kill"
if [ "${NODE_ENV}" == "production" ]; then
echo "Cleaning project..."
npm run clean
echo "Installing dependencies..."
rm -rf node_modules/
yarn install --frozen-lockfile
git log -n 1 --pretty=format:"%H" > ../version
fi
rebuild
fi
echo "Starting bot in ${NODE_ENV}..."
cd build/
if [ "${NODE_ENV}" == "dry-run" ] || [ "${NODE_ENV}" == "ci" ]; then
exec env RUN_ID=$RUN_ID node --trace-warnings "${PWD}/kmq.js"
elif [ "${NODE_ENV}" == "development" ]; then
exec env RUN_ID=$RUN_ID node --trace-warnings --inspect=9229 "${PWD}/kmq.js"
elif [ "${NODE_ENV}" == "production" ]; then
exec env RUN_ID=$RUN_ID node --trace-warnings "${PWD}/kmq.js"
fi