nielsstampe
nielsstampe

Reputation: 1364

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.

Upvotes: 2

Views: 901

Answers (2)

edi9999
edi9999

Reputation: 20574

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

Upvotes: 1

Oliver Stark
Oliver Stark

Reputation: 196

I suggest to check if your environment dedection works as expected.

$ php artisan env

If not, your can force the environment for artisan commands, like so:

$ php artisan migrate --env=test_server

Upvotes: 1

Related Questions