## Running docker image
-> docker run --rm -d -p 8074:8074 --name anna-adml-http anna-adml-http:<version>
+> docker run --rm -d -p 8074:8074 --name anna-adml-http anna-adml-http:<version> [entrypoint arguments: <[ft]|st>]
+
+Entrypoint arguments are passed to ADML start script (`/opt/adml/start.sh` inside the container), and are mainly preconfigured variants for `ADML` command-line arguments. So, `ft` stands for `function test` (debug traces, traffic logs in real time, etc.) and `st` is `system test` (warning level for traces, no traffic logs dumped, etc.).
Service port is **8074**.
ENDPOINT=http://localhost:8074
PORT=$(echo ${ENDPOINT} | cut -d: -f3)
C_NAME=anna-adml-http
+# Entrypoint arguments (ft/st):
+EXTRA_ARGUMENTS= # default is ft (function test: debug traces and traffic logs)
+EXTRA_ARGUMENTS=st
+
+VARIANT=${1:-Release}
#############
# EXECUTION #
#############
+
+echo
+echo "Variant: ${VARIANT}"
+echo "Remember usage: $0 [variant: <[Release]|Debug]>"
+echo
+
cd $(dirname $0)
# Basic requirement:
echo "Requirement found !"
echo
-echo "Rebuild ADML HTTP service image (y/n) [y]:"
+echo "Rebuild ADML HTTP service image (y/n) [n]:"
read opt
-[ -z "${opt}" ] && opt=y
-[ "${opt}" = "y" ] && ${REPO_DIR}/tools/build-anna-adml-http
+[ -z "${opt}" ] && opt=n
+if [ "${opt}" = "y" ]
+then
+ ${REPO_DIR}/tools/build-anna-adml-http ${VARIANT}
+fi
version=$(${REPO_DIR}/tools/version)
+[ "${VARIANT}" = "Debug" ] && { version=${version}-debug ; C_NAME=${C_NAME}-debug ; }
echo "Restart ADML HTTP service image (version '${version}') ..."
-docker kill ${C_NAME} >/dev/null
-cid=$(docker run --rm -d -p ${PORT}:${PORT} --name ${C_NAME} anna-adml-http:${version})
+docker kill ${C_NAME} &>/dev/null
+cid=$(docker run --rm -d -p ${PORT}:${PORT} --name ${C_NAME} anna-adml-http:${version} ${EXTRA_ARGUMENTS} >/dev/null)
+[ $? -ne 0 ] && exit 1
+
echo "Container id: ${cid} (deployed as '${C_NAME}')"
echo
echo "Configuring services (${SERVICES}) ..."
sleep 4 # wait for docker running
-nghttp -H ":method: POST" -d ${SERVICES} ${ENDPOINT}/services
-echo
+nghttp -H ":method: POST" -d ${SERVICES} ${ENDPOINT}/services | tee .response.json | jq '.'
+result=$(cat .response.json | jq -r '.["success"]')
+rm .response.json
+if [ "${result}" = "false" ]
+then
+ echo
+ echo "Check if another ADML HTTP service (anna-adml-http*) has been started (port ${PORT} busy ?)"
+ exit 1
+fi
echo
echo -n "Waiting for server-client connection ..."
while true
do
- docker exec -it ${C_NAME} bash -c "netstat -p $(pgrep ADML) --numeric-ports | grep -w 3868 | grep -w ESTABLISHED" >/dev/null
+ docker exec -it ${C_NAME} bash -c "netstat -p \$(pgrep ADML) --numeric-ports | grep -w 3868 | grep -w ESTABLISHED" >/dev/null
[ $? -eq 0 ] && break
echo -n .
sleep 1