laravel / octane

Supercharge your Laravel application's performance.
https://laravel.com/docs/octane
MIT License
3.78k stars 296 forks source link

Undefined array key "rpcPort" #277

Closed obrunsmann closed 3 years ago

obrunsmann commented 3 years ago

Description:

In a new Laravel app that is still pretty empty, I installed Octane/Swoole. The first 2-3 deploys worked great, now I get the following message when I run php artisan octane:reload:

   INFO  Reloading workers...

   ErrorException

  Undefined array key "rpcPort"

  at vendor/laravel/octane/src/RoadRunner/ServerProcessInspector.php:43
     39▕     {
     40▕         [
     41▕             'state' => [
     42▕                 'host' => $host,
  ➜  43▕                 'rpcPort' => $rpcPort,
     44▕             ],
     45▕         ] = $this->serverStateFile->read();
     46▕
     47▕         tap($this->processFactory->createProcess([

      +16 vendor frames
  17  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

Runs on a freshly created ubuntu 20.04 LTS

Run command:

php /home/ploi/xx/artisan octane:start --port=8000 --server=swoole --max-requests=500 --workers=auto --no-interaction
sy-records commented 3 years ago

use

php artisan octane:reload --server=swoole
obrunsmann commented 3 years ago

Oh my. Yes, that was the solution. Thank you.

I just did some more research on why this doesn't happen to me on another project, is also already running on Octane. The info for those who may encounter the same problem:

I actually just didn't change the server configuration in the config/octane.php to Swoole:

'server' => env('OCTANE_SERVER', 'roadrunner'),

and then run octane with

php artisan octane:start --server=swoole

So the best solution is to set the config octane.server to swoole or alternatively to work with the CLI argument --server swoole.

php artisan octane:reload checks for the octane.server config to decide which server needs the reload.