chore(bulk-mailer): Stop all processing on error.

bulk-mailer will exit with a non-0 status code if there is an error.
The bash scripts check exit codes and abort on non-0
This commit is contained in:
Shane Tomlinson 2016-04-08 20:11:12 +01:00 коммит произвёл Vijay Budhram
Родитель f02e29237a
Коммит de8e355de0
3 изменённых файлов: 4 добавлений и 3 удалений

Просмотреть файл

@ -79,7 +79,6 @@ P.resolve()
}) })
}) })
.then(null, function (error) { .then(null, function (error) {
console.error('error', error)
log.error({ log.error({
op: 'send.abort', op: 'send.abort',
err: error err: error
@ -89,8 +88,7 @@ P.resolve()
.then(writeErrors) .then(writeErrors)
.then(writeUnsent) .then(writeUnsent)
.then(function () { .then(function () {
console.log('bye bye!') process.exit(runningError || errorCount ? 1 : 0)
process.exit(runningError ? 1 : 0)
}) })
var fakeEmailCount = 0 var fakeEmailCount = 0

Просмотреть файл

@ -10,4 +10,5 @@ DIRNAME=${1}
for BATCH in $(find ${DIRNAME} -name "*.json" -type f); do for BATCH in $(find ${DIRNAME} -name "*.json" -type f); do
echo ${BATCH} $PWD echo ${BATCH} $PWD
./reset-send-batch.sh ${BATCH} ./reset-send-batch.sh ${BATCH}
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
done done

Просмотреть файл

@ -28,11 +28,13 @@ fi
echo ${BATCH} echo ${BATCH}
node must-reset.js -i ${BATCH} node must-reset.js -i ${BATCH}
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
### TODO If we need more delay in between the batches the bulk-mailer itself sends, add a `-d <seconds> to the below line. ### TODO If we need more delay in between the batches the bulk-mailer itself sends, add a `-d <seconds> to the below line.
### If instead of sending 10 emails at a time, the mailer should send 5 (or some other number), -b <batch_size> ### If instead of sending 10 emails at a time, the mailer should send 5 (or some other number), -b <batch_size>
### TODO Finally, when sending for real for real, the --send option needs to be added. ### TODO Finally, when sending for real for real, the --send option needs to be added.
node bulk-mailer.js -i ${BATCH} -t password_reset_required -e ${ERRORS_OUTPUT} -u ${UNSENT_OUTPUT} --real node bulk-mailer.js -i ${BATCH} -t password_reset_required -e ${ERRORS_OUTPUT} -u ${UNSENT_OUTPUT} --real
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
# once the batch is completed, remove the batch file to # once the batch is completed, remove the batch file to