exaco / laravel-octane-dockerfile

Production-ready Dockerfile for Laravel Octane (FrankenPHP, Swoole, RoadRunner) powered web services and microservices. Done right.
MIT License
621 stars 94 forks source link

PHP Fatal error: Uncaught Error: Class "Laravel\Octane\Octane" not found in /var/www/html/vendor/laravel/octane/src/Stream.php:56 #71

Closed UNILORN closed 6 months ago

UNILORN commented 7 months ago

When I run the built image on kubernetes, I get the following error.

Container mode: http                                                                                                                                                                                                                         
Octane Server: swoole                                                                                                                                                                                                                        

   INFO  Clearing cached bootstrap files.                                                                                                                                                                                                    

  cache .......................................................... 6.53ms DONE                                                                                                                                                               
  compiled ....................................................... 1.27ms DONE                                                                                                                                                               
  config ......................................................... 0.61ms DONE                                                                                                                                                               
  events ......................................................... 0.68ms DONE                                                                                                                                                               
  route .......................................................... 0.58ms DONE                                                                                                                                                               
  views ......................................................... 79.78ms DONE                                                                                                                                                               

   INFO  Events cached successfully.                                                                                                                                                                                                         

   INFO  Configuration cached successfully.                                                                                                                                                                                                  

   INFO  Routes cached successfully.                                                                                                                                                                                                         

2024-04-25 16:50:49,148 INFO Set uid to user 1000 succeeded                                                                                                                                                                                  
2024-04-25 16:50:49,150 INFO supervisord started with pid 1                                                                                                                                                                                  
2024-04-25 16:50:50,151 INFO spawned: 'octane_00' with pid 28                                                                                                                                                                                
2024-04-25 16:50:51,152 INFO success: octane_00 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)                                                                                                                

   INFO  Server running…                                                                                                                                                                                                                     

  Local: http://0.0.0.0:80                                                                                                                                                                                                                   

  Press Ctrl+C to stop the server                                                                                                                                                                                                            

PHP Fatal error:  Uncaught Error: Class "Laravel\Octane\Octane" not found in /var/www/html/vendor/laravel/octane/src/Stream.php:56                                                                                                           
Stack trace:                                                                                                                                                                                                                                 
#0 /var/www/html/vendor/laravel/octane/bin/createSwooleServer.php(19): Laravel\Octane\Stream::shutdown()                                                                                                                                     
#1 /var/www/html/vendor/laravel/octane/bin/swoole-server(35): require('...')                                                                                                                                                                 
#2 {main}                                                                                                                                                                                                                                    
  thrown in /var/www/html/vendor/laravel/octane/src/Stream.php on line 56                                                                                                                                                                    
Fatal error: Uncaught Error: Class "Laravel\Octane\Octane" not found in /var/www/html/vendor/laravel/octane/src/Stream.php:56                                                                                                                
2024-04-25 16:50:52,441 INFO exited: octane_00 (exit status 255; not expected)

Adding variables_order = "EGPCS" to php.ini failed as well.

The composer.json contains the following octane and confirms that the composer install has been done correctly.

{
"require": {
        "php": "^8.2",
        "darkaonline/l5-swagger": "^8.6",
        "guzzlehttp/guzzle": "^7.2",
        "laravel/framework": "^11.0",
        "laravel/octane": "^2.3",
        "laravel/sanctum": "^4.0",
        "laravel/telescope": "^5.0",
        "laravel/tinker": "^2.8",
        "spatie/laravel-permission": "^6.4"
    },
}

I have minimal k8s resources set up for startup, is that a problem?

resources:
    limits:
      cpu: 300m
      memory: 450Mi
    requests:
      cpu: 100m
      memory: 180Mi

How can I solve this problem...? I would be grateful for your wisdom.

smortexa commented 7 months ago

Is your Octane version up-to-date? There's a potential issue (laravel/octane#839) that might be addressed in a later version (laravel/octane#852).

UNILORN commented 7 months ago

Thank you very much! Changing the port used from 80 to 9000 worked fine.

UNILORN commented 6 months ago

@smortexa

I removed try,catch from createSwooleServer.php in Laravel Octane main body and checked the error.

We sent you a Pull Request in #73, but it turned out that port 80 could not be started as a non-privileged user.

We found that port 8000 can be started successfully.

Could you please confirm this?

2024-04-30 01:25:38,428 INFO success: octane_00 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)                                                                                                                                                        

   INFO  Server running…                                                                                                                                                                                                                                                             

  Local: http://0.0.0.0:80                                                                                                                                                                                                                                                           

  Press Ctrl+C to stop the server                                                                                                                                                                                                                                                    

PHP Fatal error:  Uncaught Swoole\Exception: failed to listen server port[0.0.0.0:80], Error: Permission denied[13] in /var/www/html/vendor/laravel/octane/bin/createSwooleServer.php:10                                                                                             
Stack trace:                                                                                                                                                                                                                                                                         
#0 /var/www/html/vendor/laravel/octane/bin/createSwooleServer.php(10): Swoole\Server->__construct()                                                                                                                                                                                  
#1 /var/www/html/vendor/laravel/octane/bin/swoole-server(35): require('...')                                                                                                                                                                                                         
#2 {main}                                                                                                                                                                                                                                                                            
  thrown in /var/www/html/vendor/laravel/octane/bin/createSwooleServer.php on line 10                                                                                                                                                                                                
Fatal error: Uncaught Swoole\Exception: failed to listen server port[0.0.0.0:80], Error: Permission denied[13] in /var/www/html/vendor/laravel/octane/bin/createSwooleServer.php:10

The log for the change to port 8000 is as follows

2024-04-30 01:43:40,237 INFO Set uid to user 1000 succeeded                                                                                                                                                                                                                          
2024-04-30 01:43:40,239 INFO supervisord started with pid 1                                                                                                                                                                                                                          
2024-04-30 01:43:41,240 INFO spawned: 'octane_00' with pid 25                                                                                                                                                                                                                        
2024-04-30 01:43:42,241 INFO success: octane_00 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)                                                                                                                                                        

   INFO  Server running…                                                                                                                                                                                                                                                             

  Local: http://0.0.0.0:8000                                                                                                                                                                                                                                                         

  Press Ctrl+C to stop the server                                                                                                                                                                                                                                                    

  200    GET /health ........................................ 17.22 mb 62.77 ms                                                                                                                                                                                                      
  200    GET /health ......................................... 17.35 mb 3.90 ms