-
Notifications
You must be signed in to change notification settings - Fork 11
/
dev.sh
executable file
·122 lines (100 loc) · 3.21 KB
/
dev.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/env bash
# --------
# dev.sh
# --------
# Builds, deploys, configures and runs a CWS console/worker setup locally for development.
ROOT=${1}
LDAP_USERNAME=${2}
DB_TYPE=${3}
DB_HOST=${4}
DB_PORT=${5}
DB_NAME=${6}
DB_USER=${7}
DB_PASS=${8}
ES_PROTOCOL=${9}
ES_HOST=${10}
ES_INDEX_PREFIX=${11}
ES_PORT=${12}
ES_USE_AUTH=${13}
ES_USERNAME=${14}
ES_PASSWORD=${15}
ENABLE_CLOUD_AS=${16}
SECURITY_SCHEME=${17}
THIS_HOSTNAME=${18}
NOTIFICATION_EMAILS=${19}
ADMIN_FIRSTNAME=${20}
ADMIN_LASTNAME=${21}
ADMIN_EMAIL=${22}
NUM_WORKERS=${23}
WORKER_MAX_NUM_RUNNING_PROCS=${24}
WORKER_ABANDONED_DAYS=${25}
source ${ROOT}/utils.sh
# Only for the Mac users
[[ `uname -s` != "Darwin" ]] && return
print 'Building CWS libraries and creating distribution archive'
${ROOT}/build.sh
DIST=${ROOT}/dist
SERVER_DIST='cws_server.tar.gz'
# -------------------
# CONFIGURE CONSOLE
# -------------------
print "Preparing console installation files..."
mkdir -p ${DIST}/console-only
tar --directory=${DIST}/console-only -zxf ${DIST}/${SERVER_DIST}
print "Generating console installation properties..."
auto_conf_data console-only "$@" ${ROOT}/auto_conf_console.dat
print "Configuring console installation..."
${DIST}/console-only/cws/configure.sh ${ROOT}/auto_conf_console.dat Y
if [[ $? -gt 0 ]]; then
prompt_to_continue "Error during configuration (see above) Continue? (y/n): "
fi
# -----------------------------------------
# COPY IN DEVELOPMENT BPMN FILES
# used for development and testing purposes
# -----------------------------------------
cp ${ROOT}/install/dev/bpmn/*.bpmn ${DIST}/console-only/cws/bpmn
print "Done configuring console installation."
# --------------
# START CONSOLE
# --------------
LOG_FILE="server/apache-tomcat-${TOMCAT_VER}/logs/cws.log"
BASE_PORT=8000
tab ${DIST}/console-only/cws "./start_cws.sh -d $BASE_PORT; tail -f $LOG_FILE"
print "Waiting for console startup..."
cws_console_host=$(grep cws_console_host ${ROOT}/auto_conf_console.dat | cut -d '=' -f2)
cws_console_ssl_port=$(grep cws_console_ssl_port ${ROOT}/auto_conf_console.dat | cut -d '=' -f2)
while ! curl -k -s https://${cws_console_host}:${cws_console_ssl_port}/cws-ui/login > /dev/null 2>&1; do
sleep 5
print "Retry wait for console"
done
print "Console is now running!"
# -----------------
# CONFIGURE WORKERS
# -----------------
if [[ -z "$NUM_WORKERS" ]]; then
NUM_WORKERS=1
fi
for ((WORKER_NUM=1; WORKER_NUM <= $NUM_WORKERS; WORKER_NUM++)); do
print "Configuring worker $WORKER_NUM installation...";
WORKER_TAG="worker${WORKER_NUM}"
mkdir -p ${DIST}/${WORKER_TAG}
tar --directory=${DIST}/${WORKER_TAG} -zxf ${DIST}/${SERVER_DIST}
auto_conf_data ${WORKER_TAG} "$@" ${ROOT}/auto_conf.dat
${DIST}/${WORKER_TAG}/cws/configure.sh ${ROOT}/auto_conf.dat
if [[ $? -gt 0 ]]; then
prompt_to_continue "Error during configuration (see above) Continue? (y/n): "
fi
done
# -------------
# START WORKERS
# -------------
for ((WORKER_NUM=1; WORKER_NUM <= $NUM_WORKERS; WORKER_NUM++)); do
sleep 5
print "Starting worker ${WORKER_NUM}..."
WORKER_TAG="worker${WORKER_NUM}"
WORKER_PORT=$((BASE_PORT + WORKER_NUM))
tab ${DIST}/${WORKER_TAG}/cws "./start_cws.sh -d $WORKER_PORT; tail -f $LOG_FILE"
done
rm -f ${ROOT}/auto_conf.dat
rm -f ${ROOT}/auto_conf_console.dat
print "Finished"