3

我对 Laravel Envoy 有疑问。我编写了用于在服务器上部署的脚本,我正在使用
envoy run deploy --environment=staging
调用该脚本,但是当发生错误时,我无法从生产中看到错误。例如,php artisan migrate 发生错误,我可以捕获发生错误但无法获取环境的任务。这是我的代码:

@error

@slack('hook', '#deploy', "Deploy failed on {$environment} error: 
$task")
exit;
@enderror

松弛通道部署的输出是:
Deploy failed on error: migrate-db

4

1 回答 1

1

听起来您的 Envoy 脚本在migrate-db任务中有错误。如果不发布代码,就很难判断该任务发生了什么。我建议echo在任务中使用一个简单的方法来让脚本首先完成。

envoy run deploy --env=staging

@servers(['web' => '127.0.0.1'])

@setup
    $env  = isset($env) ? $env : "localhost";
    $host = gethostname();
    $hook =  "https://hooks.slack.com/services/XXX";
    $channel = "#your-channel";
@endsetup

@story('deploy')
    migrate-db
@endstory

@task('migrate-db')
    echo 'migrate-db'
@endtask

@error
    @slack($hook, $channel, "Deploy failed on [$env], hostname: $host");
    echo "Deploy failed on [$env], hostname: $host\r\n";
@enderror

@finished
    @slack($hook, $channel, "Deploy succeeded on [$env], hostname: $host");
    echo "Deploy succeeded on [$env], hostname: $host\r\n";
@endfinished
于 2018-03-17T23:09:22.323 回答