Search code examples
laravelsshfortrabbitlaravel-envoy

Laravel Envoy on fortrabbit


I've setup a Laravel app on a Fortrabbit server. I can do the following

$ ssh user@server
$ cd htdocs
$ php artisan migrate

Which works perfectly fine.

But I'm trying to use Envoy for tasks like this. So I've made a simple task:

@servers(['test' => 'user@server'])

@task('task:test', ['on' => 'test'])
    cd htdocs
    php artisan migrate
@endtask

However, I encounter the following issue when doing so:

$ envoy run task:test

[user@server]: \(><)/ Welcome to the rabbit hole. \(><)/
[user@server]: [PDOException] SQLSTATE[HY000] [2002] No such file or directory

It might be worth noting that the db connection uses credentials from ENV variables set in the Fortrabbit interface. If i SSH into the server and do env, all the variables are listed as they should be. But when doing

$ ssh user@server env

I only get a small portion of the Fortrabbit server ENV variables.

I can't figure out what could be the cause of the error, and I haven't been able to find anything when asking Google. Could anybody shed a bit of light on this? Thanks alot.


Solution

  • As @ukautz said, the session scripts are not executed by envoy, that's why some of your environment variables are missing.

    Here's what I did:

    @servers(['dev'=>"<<user@server>>"])
    @task('list')
        . /etc/profile.envvars
        env
    @endtask
    

    That showed all ENV variables, including those set by you on the dashboard !

    Your script should work with this:

    @servers(['test' => 'user@server'])
    @task('task:test', ['on' => 'test'])
        . /etc/profile.envvars
        cd htdocs
        php artisan migrate
    @endtask