From 1154d14bff6ed6a3c87f96222ccd05c523e81834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Sko=C5=99epa?= <jakub@skorepa.info> Date: Thu, 7 Apr 2016 19:48:16 +0200 Subject: [PATCH] Better error handling --- .gitlab-ci.yml | 2 ++ index.js | 1 + upload | 24 ++++++++++++++++++------ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 18aa53a8..befbc381 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,6 +3,8 @@ before_script: - ./configure.sh upload: + only: + - master script: - ./upload diff --git a/index.js b/index.js index bd93f397..97ca44b1 100755 --- a/index.js +++ b/index.js @@ -51,6 +51,7 @@ var sitegin = function(config) { .catch(function(e) { isRunning = false; console.log('Generator crashed in',moment().diff(startTime,'seconds'),'seconds') + if(config.options.noserver) process.exit(13); if(runAgain) run(); if(e.stack) console.log(e.stack) diff --git a/upload b/upload index f7ea1bf1..3f62eef6 100755 --- a/upload +++ b/upload @@ -8,7 +8,12 @@ fi rm -rf build mkdir -p build/theme time node index.js --noserver -echo "Site compiled" +echo "Site compilation ended with status code $?" +if [ $? -ne 0 ] +then + echo "Error detected. Exitting." + exit 1 +fi chmod a+X build -R USER=ok1kvk.cz-www-nove @@ -17,22 +22,29 @@ MAX_RETRIES=2 RECONNECT_INTERVAL=5 echo "======================================================================" -echo "Uploading to nove.ok1kvk.cz" +echo "Uploading to $HOST" if [ "$1" == "ftp" ]; then echo "Using FTP" - time lftp -c "set cmd:fail-exit yes;\ + time lftp -e "set cmd:fail-exit yes;\ set net:timeout 5;\ set net:reconnect-interval-base $RECONNECT_INTERVAL;\ set net:max-retries $MAX_RETRIES;\ set ftp:ssl-allow no;\ open --user $USER --env-password ftp://$HOST/;\ - mirror -c --verbose=9 -e -R -L ./build /" + mirror -c --verbose=9 -e -R -L ./build /;\ + exit 0;" + echo "LFTP finished with return code $?" else echo "Using SFTP" - time lftp -c "set cmd:fail-exit yes;\ + time lftp -e "set sftp:auto-confirm yes;\ + set cmd:fail-exit yes;\ set net:timeout 5;\ set net:reconnect-interval-base $RECONNECT_INTERVAL;\ set net:max-retries $MAX_RETRIES;\ open --user $USER --env-password -p 2121 sftp://$HOST/;\ - mirror -c --verbose=9 -e -R -L ./build /" + mirror -c --verbose=9 -e -R -L ./build /;\ + exit 0;" + echo "LFTP finished with return code $?" fi +exit 0 + -- GitLab