我有Laravel 5.2并尝试做这样的事情
namespace App\Jobs;
use App\Jobs\Job;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;
class MachineCreate extends Job implements ShouldQueue
{
use InteractsWithQueue, SerializesModels;
/**
* Create a new job instance.
*
*/
public function __construct()
{
//
}
/**
* Execute the job.
*
*/
public function handle()
{
$process = new Process('docker-machine create --driver digitalocean --digitalocean-access-token *** do-test');
$process->setTimeout(600);
$process->run();
// executes after the command finishes
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
}
}
每次我这样做都会有错误:
Driver "digitalocean" not found. Do you have the plugin binary accessible in your PATH?
但是,如果我在php artisan tinker
中做同样的事情我没有错误,那么事情就可以了。
任何想法我做错了什么?
答案 0 :(得分:1)
我通过使用ProcessBulder
解决了这个问题$builder->setPrefix('/usr/local/bin/docker-machine');
$process = $builder
->setArguments(array(
'create',
'--driver', 'digitalocean',
'--digitalocean-access-token', '***',
'do-test'))
->getProcess();
$process->run();
但是,我不知道这个问题的原因是什么......