Laravel Messenger: Abort Error

Is it possible to abort errors or cause another task if the command fails?

This does not work:

@task('migrate', ['on' => 'web'])
    cd {{ $currentReleaseDir }};
    php artisan migrate || exit 1;
@endtask

It does not work with the message (I know that I can run it --force, this is just a way to make the command unsuccessful for testing):

**************************************
*     Application In Production!     *
**************************************

But then it runs the rest of the deployment script.

+4
source share
1 answer

Yes you can use:

@error
   echo $task;
   exit; /*Or Do any other processing*/
@enderror

it outputs

<?php $__container->error(function($task) {
    echo $task;
    exit; /*Or Do any other processing*/
}); ?>

Listed here are the compiler functions here https://github.com/laravel/envoy/blob/master/src/Compiler.php

+4
source

Source: https://habr.com/ru/post/1615461/


All Articles