You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I came here to do something else, but could not help cleaning up the bootstrap
code.
* add die() helper
* pull the container ID into an environment variable right away instead of
interpolating it every time
* we don't need to write out to a file prior to piping it into docker
* use $() instead of backticks
* tidied up messaging from failed docker commits
(exec cat "$tmp_input_file"|$docker_path run --shm-size=512m $user_args$links"${env[@]}" -e DOCKER_HOST_IP="$docker_ip" --cidfile $cidbootstrap -i -a stdin -a stdout -a stderr $volumes$image \
687
-
/bin/bash -c "$pups_command") || ERR=$?
683
+
echo"$input"|$docker_path run --shm-size=512m $user_args$links"${env[@]}" -e DOCKER_HOST_IP="$docker_ip" --cidfile "$cidbootstrap" -i -a stdin -a stdout -a stderr $volumes$image \
684
+
/bin/bash -c "$pups_command"
685
+
BOOTSTRAP_EXITCODE=$?
688
686
689
-
rm -f "$tmp_input_file"
687
+
CONTAINER_ID=$(cat "$cidbootstrap")
688
+
rm -f "$cidbootstrap"
690
689
691
-
unset FAILED
692
690
# magic exit code that indicates a retry
693
-
if [[ "$ERR"== 77 ]];then
694
-
$docker_path rm `cat $cidbootstrap`
695
-
rm $cidbootstrap
691
+
if [[ $BOOTSTRAP_EXITCODE-eq 77 ]];then
692
+
$docker_path rm "$CONTAINER_ID"
696
693
exit 77
697
-
elif [[ "$ERR"> 0 ]];then
698
-
FAILED=TRUE
699
-
fi
694
+
elif [[ $BOOTSTRAP_EXITCODE-gt 0 ]];then
695
+
echo"bootstrap failed with exit code $BOOTSTRAP_EXITCODE"
696
+
echo"** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one."
697
+
echo"./discourse-doctor may help diagnose the problem."
700
698
701
-
if [[ $FAILED="TRUE" ]];then
702
-
if [[ !-z"$DEBUG" ]];then
703
-
$docker_path commit `cat $cidbootstrap`$local_discourse/$config-debug ||echo'FAILED TO COMMIT'
704
-
echo"** DEBUG ** Maintaining image for diagnostics $local_discourse/$config-debug"
0 commit comments