Can't run Laravel Envoy with exec (works in command line but doesn't with Artisan::call)

439 views Asked by At

I have an envoy script which I am triggering within Laravel Command.

php artisan proxy:update

public function handle() {
   exec("envoy run update");
}

If I run this on command line as php artisan proxy:update, it works.

However if I run this inside my Laravel app as Artisan::call('proxy:configure'); it doesn't work.


In console whoami = vagrant; likewise in my command exec('whoami') is also vagrant.


If I change it to

$out =  shell_exec('envoy run update');
dd($out);

In command-line it shows the output, but with Artisan::call(), it returns empty string.


What might be the issue for being able to use exec() with artisan command?


1

There are 1 answers

0
senty On BEST ANSWER

As far as I understand, php-fpm was blocking it. I tried using Symfony's Process instead of exec() and I was getting "terminated". Then I moved Artisan::call() to Artisan::queue() and it worked. I'd be happy to know if anyone has any other explanations.

Update: I created a queue that is run by deployer user which has sudo privileges (normally www-data run my queues). Now it works perfectly.