Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PhpExecutableFinder for Octane server command #112

Merged
merged 5 commits into from
Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/Commands/Concerns/InstallsRoadRunnerDependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Spiral\RoadRunner\Http\PSR7Worker;
use Symfony\Component\Process\Exception\ProcessSignaledException;
use Symfony\Component\Process\ExecutableFinder;
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\Process;

trait InstallsRoadRunnerDependencies
Expand Down Expand Up @@ -61,12 +62,13 @@ protected function ensureRoadRunnerPackageIsInstalled()
protected function findComposer()
{
$composerPath = getcwd().'/composer.phar';
$phpPath = (new PhpExecutableFinder)->find();

if (file_exists($composerPath)) {
return '"'.PHP_BINARY.'" '.$composerPath;
if (! file_exists($composerPath)) {
$composerPath = (new ExecutableFinder())->find('composer');
}

return 'composer';
return '"'.$phpPath.'" '.$composerPath;
}

/**
Expand All @@ -88,6 +90,7 @@ protected function ensureRoadRunnerBinaryIsInstalled(): string

if ($this->confirm('Unable to locate RoadRunner binary. Should Octane download the binary for your operating system?', true)) {
tap(new Process(array_filter([
(new PhpExecutableFinder)->find(),
'./vendor/bin/rr',
'get-binary',
'-n',
Expand Down
3 changes: 2 additions & 1 deletion src/Commands/StartRoadRunnerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Laravel\Octane\RoadRunner\ServerProcessInspector;
use Laravel\Octane\RoadRunner\ServerStateFile;
use Symfony\Component\Console\Command\SignalableCommandInterface;
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\Process;

class StartRoadRunnerCommand extends Command implements SignalableCommandInterface
Expand Down Expand Up @@ -66,7 +67,7 @@ public function handle(ServerProcessInspector $inspector, ServerStateFile $serve
$server = tap(new Process(array_filter([
$roadRunnerBinary,
'-o', 'http.address='.$this->option('host').':'.$this->option('port'),
'-o', 'server.command=php ./vendor/bin/roadrunner-worker',
'-o', 'server.command='.(new PhpExecutableFinder)->find().' ./vendor/bin/roadrunner-worker',
'-o', 'http.pool.num_workers='.$this->workerCount(),
'-o', 'http.pool.max_jobs='.$this->option('max-requests'),
'-o', 'http.pool.supervisor.exec_ttl='.$this->maxExecutionTime(),
Expand Down