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

Resolve custom vendor folder #555

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion bin/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ function dd(...$vars)
|
*/

if (! is_file($autoload_file = $basePath.'/vendor/autoload.php')) {
$vendorPath = getenv('COMPOSER_VENDOR_DIR') ?: $basePath.'/vendor';

if (! is_file($autoload_file = $vendorPath.'/autoload.php')) {
fwrite(STDERR, "Composer autoload file was not found. Did you install the project's dependencies?".PHP_EOL);

exit(10);
Expand Down
3 changes: 2 additions & 1 deletion src/Commands/Concerns/InstallsRoadRunnerDependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Laravel\Octane\Commands\Concerns;

use Illuminate\Support\Env;
use Illuminate\Support\Str;
use Laravel\Octane\RoadRunner\Concerns\FindsRoadRunnerBinary;
use RuntimeException;
Expand Down Expand Up @@ -163,7 +164,7 @@ protected function downloadRoadRunnerBinary()
{
tap(new Process(array_filter([
(new PhpExecutableFinder)->find(),
'./vendor/bin/rr',
Env::get('COMPOSER_VENDOR_DIR', base_path('vendor')).'/bin/rr',
'get-binary',
'-n',
'--ansi',
Expand Down
23 changes: 22 additions & 1 deletion src/Commands/StartRoadRunnerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Laravel\Octane\Commands;

use Illuminate\Support\Env;
use Illuminate\Support\Str;
use InvalidArgumentException;
use Laravel\Octane\RoadRunner\ServerProcessInspector;
Expand Down Expand Up @@ -72,14 +73,16 @@ public function handle(ServerProcessInspector $inspector, ServerStateFile $serve

$this->writeServerStateFile($serverStateFile);

$vendorDir = Env::get('COMPOSER_VENDOR_DIR', base_path('vendor'));

$this->forgetEnvironmentVariables();

$server = tap(new Process(array_filter([
$roadRunnerBinary,
'-c', $this->configPath(),
'-o', 'version=2.7',
'-o', 'http.address='.$this->option('host').':'.$this->option('port'),
'-o', 'server.command='.(new PhpExecutableFinder)->find().' '.base_path(config('octane.roadrunner.command', 'vendor/bin/roadrunner-worker')),
'-o', 'server.command='.(new PhpExecutableFinder)->find().' '.$this->workerBinary($vendorDir),
'-o', 'http.pool.num_workers='.$this->workerCount(),
'-o', 'http.pool.max_jobs='.$this->option('max-requests'),
'-o', 'rpc.listen=tcp://'.$this->option('host').':'.$this->rpcPort(),
Expand All @@ -95,6 +98,7 @@ public function handle(ServerProcessInspector $inspector, ServerStateFile $serve
'APP_ENV' => app()->environment(),
'APP_BASE_PATH' => base_path(),
'LARAVEL_OCTANE' => 1,
'COMPOSER_VENDOR_DIR' => $vendorDir,
]))->start();

$serverStateFile->writeProcessId($server->getPid());
Expand Down Expand Up @@ -262,4 +266,21 @@ protected function stopServer()
'--server' => 'roadrunner',
]);
}

/**
* Get the roadrunner-worker binary.
*
* @param string $vendorDir
* @return string
*/
protected function workerBinary(string $vendorDir)
{
$command = config('octane.roadrunner.command');

if (! empty($command)) {
return base_path($command);
}

return $vendorDir.'/bin/roadrunner-worker';
}
}