Skip to content
This repository has been archived by the owner on Aug 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #18 from mageddo/feature/MG-401
Browse files Browse the repository at this point in the history
Container stop takes forever
  • Loading branch information
mageddo authored Sep 6, 2017
2 parents 48df696 + 64822c0 commit e59e556
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
3 changes: 3 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 2.9.2
* Fix container stop taking forever

# 2.9.1
* Fixing HTML not rendering when code in plain mode

Expand Down
37 changes: 37 additions & 0 deletions bookmark-notes
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e59e556

Please # to comment.