Skip to content

Commit 28d6d56

Browse files
committed
Improve deploy check when app repeatedly crashes
The ip address changes each time the app restarts, which caused problems. To improve it: - The ip address is retrieved right before it is used - If there is no ip address, it skips the curl command - Add a 10 second timeout to the curl command. If the ip address is no longer used by docker, it will instead try to load the page from a remote server with the ip address, which can take a while. - If the app is restarting during 10 checks, it will revert the app without waiting the full time
1 parent 6f21f78 commit 28d6d56

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ The `mup status` command gives an overview of what is running on the servers and
2525
- `mup init` will create a `.deploy` folder when run in the same folder as a Meteor app
2626
- When mup can find a meteor app near to where `mup init` is run, the default config's `app.path` will be the path to that app
2727
- When a deploy fails, the last 200 instead of 100 lines of the app's logs are shown
28-
- More of the logs are shown when a command fails
28+
- More of the output is shown when a command fails
2929
- When copying a file fails with the error `No such file`, it will tell the user to run `mup setup` to fix it
3030
- `reconfig` hooks will now run during `mup deploy`
3131
- `--show` is no longer needed to show the config when `mup validate --scrub` is run
3232
- Add section to readme about Meteor compatibility
3333
- Initial work has been done to support Docker Swarm
3434
- When there is only one server, `mup ssh` will not require the name of a server
35+
- If the app's docker container is restarting during 10 checks, the Deployment Verifier will revert the app without waiting the full time in `deployCheckWaitTime`
36+
- Added 10 second timeout to the curl command in the Deployment Verifier
3537
- Fix retry logic for the copy file task
3638
- Fix running Prepare Bundle when image already has a `/built_app` folder
3739
- Fix alignment of list of servers when running `mup ssh` without specifying a server

src/plugins/meteor/assets/meteor-deploy-check.sh

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,42 @@ revert_app (){
3636
}
3737

3838
elaspsed=0
39+
noIPCount=0
40+
MAX_NO_IP_COUNT=10
3941
while [[ true ]]; do
42+
if [ "$elaspsed" "==" "$DEPLOY_CHECK_WAIT_TIME" ]; then
43+
revert_app
44+
exit 1
45+
fi
46+
4047
sleep 1
4148
elaspsed=$((elaspsed+1))
4249

50+
# If the container restarted, the ip address would have changed
51+
# Get the current ip address right before it is used
52+
CONTAINER_IP=$(docker inspect $APPNAME --format "{{.NetworkSettings.IPAddress}}")
53+
54+
if [[ -z $CONTAINER_IP ]]; then
55+
noIPCount=$((noIPCount+1))
56+
57+
if [ "$noIPCount" "==" "$MAX_NO_IP_COUNT" ]; then
58+
echo "Too much time spent restarting." 1>&2
59+
revert_app
60+
exit 1
61+
fi
62+
63+
continue
64+
fi
65+
66+
DEPLOY_CHECK_URL=$CONTAINER_IP<%= `:${deployCheckPort}` %>
67+
4368
# Since this failing causes the app to rollback, it should only
4469
# fail because of a problem with the app, not from problems with the config.
4570
#
4671
# --insecure Without this, it would sometimes fail when ssl is set up
4772
curl \
73+
--max-time 10 \
4874
--insecure \
4975
$DEPLOY_CHECK_URL \
5076
&& exit 0
51-
52-
if [ "$elaspsed" "==" "$DEPLOY_CHECK_WAIT_TIME" ]; then
53-
revert_app
54-
exit 1
55-
fi
5677
done

0 commit comments

Comments
 (0)