swooletw / laravel-swoole

High performance HTTP server based on Swoole. Speed up your Laravel or Lumen applications.
MIT License
4.04k stars 390 forks source link

Respond with 503 when app is not settled #470

Closed m3m0r7 closed 1 year ago

m3m0r7 commented 3 years ago

Hi! I caught errors when starting the server and refresh the page quickly. The problem answer is different timing to start-up onRequest and onWorkerStart. The bindToLaravelApp is not called by onWorkerStart when starting the server and access the page quickly. Therefore, $app field is null for a certain period of time.

I caught errors are here:

2021-03-07_at_10_49_04 2021-03-07_at_10_49_21

Arkanius commented 3 years ago

Hi, thanks for your contribution!

I didn't get why you got this error after starting your swoole event loop.

Help me understand your case:

1 - did you run php artisan swoole:http start? 2 - after run this command, did you go to any route and got this error?

m3m0r7 commented 3 years ago

@Arkanius Thanks for your replying!

1 - did you run php artisan swoole:http start?

Yes, I did

after run this command, did you go to any route and got this error?

That is correct

I didn't get why you got this error after starting your swoole event loope.

Maybe, since the life cycle of onRequest and onWorkerStart are different, the errors are displayed when the connection is made before onWorkerStart is executed. Because $app in the sandbox is null before Manager::bindToLaravelApp (actually bindSandbox) is running.