diff --git a/Dockerfile b/Dockerfile index 70f0be7..82087a9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,7 @@ ENV NODE_CONFIG_DIR=conf ARG DOWNLOAD_API_FROM_REMOTE=1 +COPY bookmark-notes "${APP_PATH}" COPY src "${APP_PATH}/src" COPY view "${APP_PATH}/view" COPY public "${APP_PATH}/public" @@ -33,4 +34,4 @@ RUN if [ "$DOWNLOAD_API_FROM_REMOTE" = "1" ] ; then apt-get update && apt-get in RUN mkdir -p $API_PATH && tar -xvf /tmp/bk-api*.tgz -C $API_PATH && rm -rf /tmp/* -CMD ["bash", "-c", "npm start & /bk-api/bk-api & tail -f /dev/null"] +CMD $APP_PATH/bookmark-notes diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index a013d3b..c7c23de 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,3 +1,6 @@ +# 2.9.2 +* Fix container stop taking forever + # 2.9.1 * Fixing HTML not rendering when code in plain mode diff --git a/bookmark-notes b/bookmark-notes new file mode 100755 index 0000000..dea0e02 --- /dev/null +++ b/bookmark-notes @@ -0,0 +1,37 @@ +#!/bin/sh + +# Start the first process +npm start & +status=$? +if [ $status -ne 0 ]; then + echo "Failed to start app: $status" + exit $status +fi + +# Start the second process +/bk-api/bk-api & +status=$? +if [ $status -ne 0 ]; then + echo "Failed to start api: $status" + exit $status +fi + +# Naive check runs checks once a minute to see if either of the processes exited. +# This illustrates part of the heavy lifting you need to do if you want to run +# more than one service in a container. The container will exit with an error +# if it detects that either of the processes has exited. +# Otherwise it will loop forever, waking up every 60 seconds + +while /bin/true; do + ps aux |grep 'npm' |grep -q -v grep + BK_APP=$? + ps aux |grep 'bk-api' |grep -q -v grep + BK_API=$? + # If the greps above find anything, they will exit with 0 status + # If they are not both 0, then something is wrong + if [ $BK_APP -ne 0 -o $BK_API -ne 0 ]; then + echo "One of the processes has already exited." + exit -1 + fi + sleep 20 +done