Fix deploy error handler: cd to safe dir before pm2
This commit is contained in:
1 parent
aabf14aaf9
commit
b6ba554386
1 file changed
+2
-1
@@ -241,6 +241,7 @@ jobs:
|
|||||||
CUTOVER_STARTED=0
|
CUTOVER_STARTED=0
|
||||||
|
|
||||||
error_handler() {
|
error_handler() {
|
||||||
|
cd /var/www/atom-nexst 2>/dev/null || cd / || true
|
||||||
echo "!!! DEPLOYMENT FAILED on line $1 !!!" >&2
|
echo "!!! DEPLOYMENT FAILED on line $1 !!!" >&2
|
||||||
# Roll back the build artifact if cutover already moved .next into place.
|
# Roll back the build artifact if cutover already moved .next into place.
|
||||||
if [ "${CUTOVER_STARTED}" = "1" ] && [ -d "${LIVE}/.next.prev" ]; then
|
if [ "${CUTOVER_STARTED}" = "1" ] && [ -d "${LIVE}/.next.prev" ]; then
|
||||||
@@ -251,7 +252,7 @@ jobs:
|
|||||||
if [ -n "${STAGE}" ] && [ -d "${STAGE}" ]; then
|
if [ -n "${STAGE}" ] && [ -d "${STAGE}" ]; then
|
||||||
git -C "${LIVE}" worktree remove --force "${STAGE}" 2>/dev/null || rm -rf "${STAGE}" || true
|
git -C "${LIVE}" worktree remove --force "${STAGE}" 2>/dev/null || rm -rf "${STAGE}" || true
|
||||||
fi
|
fi
|
||||||
pm2 start next || true
|
pm2 start next --update-env 2>/dev/null || pm2 restart next --update-env 2>/dev/null || true
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
trap 'error_handler $LINENO' ERR
|
trap 'error_handler $LINENO' ERR
|
||||||
|
|||||||
Reference in new issue
Block a user