kopia lustrzana https://github.com/c9/core
inline save deploy script
rodzic
0f329d0c74
commit
3de091f351
|
@ -0,0 +1,80 @@
|
||||||
|
_b9_check_save_deploy() {
|
||||||
|
local SERVICE
|
||||||
|
local PORT
|
||||||
|
local WAIT=default
|
||||||
|
local MODE=deploy
|
||||||
|
local SERVER=${SERVER:-localhost}
|
||||||
|
|
||||||
|
local P
|
||||||
|
for P in "$@"; do
|
||||||
|
case "$P" in
|
||||||
|
--wait=*)
|
||||||
|
WAIT=${P#*=}
|
||||||
|
;;
|
||||||
|
--mode=*)
|
||||||
|
MODE=${P#*=}
|
||||||
|
;;
|
||||||
|
--server=*)
|
||||||
|
SERVER=${P#*=}
|
||||||
|
;;
|
||||||
|
--service=*)
|
||||||
|
SERVICE=${P#*=}
|
||||||
|
PORT=$(_b9_setting $MODE $SERVICE.port)
|
||||||
|
;;
|
||||||
|
--port=*)
|
||||||
|
PORT=${P#*=}
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Illegal argument: $P"
|
||||||
|
_b9_check_save_deploy_usage
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$WAIT" == "default" ]; then
|
||||||
|
WAIT=45
|
||||||
|
elif [ "$WAIT" == "long" ]; then
|
||||||
|
WAIT=60
|
||||||
|
fi
|
||||||
|
if [ ! "$PORT" ]; then
|
||||||
|
_b9_check_save_deploy_usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
for I in {1..160}; do
|
||||||
|
if curl http://$SERVER:$PORT/_health &>/dev/null; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Service $SERVICE running, testing if it stays up for $WAIT seconds..."
|
||||||
|
|
||||||
|
if ! curl http://$SERVER:$PORT/_health?delay=$((WAIT * 1000)) &>/dev/null; then
|
||||||
|
echo "Failed: service $SERVICE at $SERVER:$PORT failed to stay up for $WAIT seconds" >&2
|
||||||
|
echo "Likely it exited with an error, shown in raygun, or the process was killed." >&2
|
||||||
|
echo "" >&2
|
||||||
|
|
||||||
|
echo "Recent errors in service log that might help debug this:" >&2
|
||||||
|
if [ "$SERVICE" ] && [ "$(type -t ssh)" != "function" ]; then
|
||||||
|
echo "Warning: ssh function not defined, trying gssh instead"
|
||||||
|
gssh $SERVER ${SERVICE//_/-}/scripts/tail-log.sh $(_b9_setting $MODE $SERVICE.logFile) >&2
|
||||||
|
elif [ "$SERVICE" ]; then
|
||||||
|
ssh $SERVER ${SERVICE//_/-}/scripts/tail-log.sh $(_b9_setting $MODE $SERVICE.logFile) >&2
|
||||||
|
fi
|
||||||
|
echo >&2
|
||||||
|
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Confirmed successful deploy to $SERVER!"
|
||||||
|
}
|
||||||
|
|
||||||
|
_b9_check_save_deploy_usage() {
|
||||||
|
echo "Use: check-deploy.sh --service=SERVICE [--server=SERVER] [--wait=WAIT_SECONDS] [--port=PORT]"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
_b9_setting() {
|
||||||
|
local MODE=$1
|
||||||
|
local SETTING="['"${2//./"']['"}"']"
|
||||||
|
$NODEJS -e "console.log(require('$B9_DIR/../settings/$MODE')()$SETTING)"
|
||||||
|
}
|
|
@ -216,7 +216,7 @@ _b9_deploy_check_one() {
|
||||||
SERVICE=${SERVICE//-/_}
|
SERVICE=${SERVICE//-/_}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! $C9_DIR/scripts/check-safe-deploy.sh --wait=$WAIT $PORT --server=$HOST --mode=$SETTINGS --service=$SERVICE; then
|
if ! _b9_check_save_deploy --wait=$WAIT $PORT --server=$HOST --mode=$SETTINGS --service=$SERVICE; then
|
||||||
echo "One or more safe deploy checks failed :(" >&2
|
echo "One or more safe deploy checks failed :(" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
"c9.ide.language": "#ad77e2cbd6",
|
"c9.ide.language": "#ad77e2cbd6",
|
||||||
"c9.ide.language.css": "#be07d72209",
|
"c9.ide.language.css": "#be07d72209",
|
||||||
"c9.ide.language.generic": "#a4023db7f6",
|
"c9.ide.language.generic": "#a4023db7f6",
|
||||||
"c9.ide.language.html": "#9be847c0ce",
|
"c9.ide.language.html": "#ae8c4f5f6e",
|
||||||
"c9.ide.language.html.diff": "#24f3608d26",
|
"c9.ide.language.html.diff": "#24f3608d26",
|
||||||
"c9.ide.language.javascript": "#c6d102471f",
|
"c9.ide.language.javascript": "#c6d102471f",
|
||||||
"c9.ide.language.javascript.immediate": "#c8b1e5767a",
|
"c9.ide.language.javascript.immediate": "#c8b1e5767a",
|
||||||
|
|
Ładowanie…
Reference in New Issue