DEV Community

Guy Warner
Guy Warner

Posted on • Updated on • Originally published at guywarner.dev

Checking site status after deploying with Laravel's Envoy

At MonitorBase we've started using Laravel's Envoy to deploy our new inhouse invoice system.

For us, our invoice system is hosted on a basic AWS set up on a single server. I'll be publishing more on our deploy process but it is a little complex due to our security protocols.

After the deploy we wanted to know if the invoice system was live and returning a 200 as it should.

(Here's our dumbed-down code with the health check to return a 200)

@setup
    $healthUrl = 'https://yoursiteurl.com';
@endsetup

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

@story('deploy')
    deployCode
    healthCheck
@endstory

@task('deployCode', ['on' => 'server'])
    deploy
@endtask

@task('healthCheck', ['on' => 'local'])
    @php
    sleep(10);
    $headers = get_headers($healthUrl);
    $response = $headers[0];
    @endphp
    echo {{ $healthUrl }} - {{ $response }}
@endtask
Enter fullscreen mode Exit fullscreen mode

Let me know if you have a better way!

Top comments (0)