Lapinskas / roadrunner-ubiquity

RoadRunner and Ubiquity integration
MIT License
9 stars 3 forks source link

Notices when following instructions #24

Closed andrei-dascalu closed 4 years ago

andrei-dascalu commented 4 years ago

Hello,

After following setup instructions, I am facing a number of warnings & notices:

WARN[0000] PHP Warning:  include(<ubiquity_project_root>/.ubiquity/config.php): failed to open stream: No such file or directory in <ubiquity_project_root>/.ubiquity/rr-worker.php on line 13
WARN[0000] PHP Warning:  include(): Failed opening '<ubiquity_project_root>/.ubiquity/config.php' for inclusion (include_path='.:/usr/local/Cellar/php/7.4.5_2/share/php/pear') in <ubiquity_project_root>/.ubiquity/rr-worker.php on line 13
WARN[0000] PHP Notice:  Trying to access array offset on value of type bool in <ubiquity_project_root>/.ubiquity/rr-worker.php on line 14
WARN[0000] PHP Notice:  Trying to access array offset on value of type bool in <ubiquity_project_root>/.ubiquity/rr-worker.php on line 14
WARN[0000] PHP Notice:  Trying to access array offset on value of type bool in <ubiquity_project_root>/.ubiquity/rr-worker.php on line 15
WARN[0000] PHP Warning:  include(<ubiquity_project_root>/.ubiquity/config.php): failed to open stream: No such file or directory in <ubiquity_project_root>/.ubiquity/rr-worker.php on line 13
WARN[0000] PHP Warning:  include(): Failed opening '<ubiquity_project_root>/.ubiquity/config.php' for inclusion (include_path='.:/usr/local/Cellar/php/7.4.5_2/share/php/pear') in <ubiquity_project_root>/.ubiquity/rr-worker.php on line 13
WARN[0000] PHP Notice:  Trying to access array offset on value of type bool in <ubiquity_project_root>/.ubiquity/rr-worker.php on line 14
WARN[0000] PHP Notice:  Trying to access array offset on value of type bool in <ubiquity_project_root>/.ubiquity/rr-worker.php on line 14
WARN[0000] PHP Notice:  Trying to access array offset on value of type bool in <ubiquity_project_root>/.ubiquity/rr-worker.php on line 15

The issues seems to be:

I am not entirely sure what would be the proper way to deal with this. Should there be a host and port in the config.php? There are already settings in .rr.yml with respect to the port (which should match at least in local). Does it make sense to have separate port/host ? In this case this needs to be handled in 3 separate files.

Also, using the Admin (after following instructions) results in the following

INFO[0012] 127.0.0.1 {102ms} 500 GET http://127.0.0.1:8090/Admin worker error: invalid data found in the buffer (possible echo)
WARN[0012] PHP Warning:  Cannot modify header information - headers already sent by (output started at <ubiquity_project_root>/vendor/phpmv/ubiquity-webtools/src/Ubiquity/controllers/admin/UbiquityMyAdminBaseController.php:260) in <ubiquity_project_root>/vendor/lapinskas/roadrunner-ubiquity/src/Request.php on line 97
WARN[0012] PHP Warning:  Cannot modify header information - headers already sent by (output started at <ubiquity_project_root>/vendor/phpmv/ubiquity-webtools/src/Ubiquity/controllers/admin/UbiquityMyAdminBaseController.php:260) in <ubiquity_project_root>/vendor/lapinskas/roadrunner-ubiquity/src/Request.php on line 97

Seems there's a flush there that breaks the way Roadrunner expects things to work.

Lapinskas commented 4 years ago

Hello @andrei-dascalu ,

The documentation is a bit outdated, I have to update it. The latest version of Uniquity devtools allows you to start your project like following:

Ubiquity serve -t=roadrunner

Required dependencies, including RoadRunner binary will be downloaded automatically and server will be started.

The prerequisite is only php-cgi installation.

andrei-dascalu commented 4 years ago

@Lapinskas Awesome! Indeed, most of the things just work when using Ubiquity

The second part (regarding Admin) still persists though:

INFO[0011] 127.0.0.1 {95.5ms} 200 GET http://127.0.0.1:8095/
INFO[0067] 127.0.0.1 {125ms} 500 GET http://127.0.0.1:8095/Admin worker error: invalid data found in the buffer (possible echo)
WARN[0127] worker.50124 killed
ERRO[0127] worker.50124 signal: killed

This is out of the box setup, running serve with roadrunner, accessing index page and following the Admin link. When using this serve command via Ubiquity tool, it doesn't seem that PHP errors/notices/warnings/etc get logged (but I assume I can pass rr parameters as well, I will try later).

andrei-dascalu commented 4 years ago

@Lapinskas I think the main issue is in the process of being solved on framework side, will close this. Thanks!

Lapinskas commented 4 years ago

Hi @andrei-dascalu,

The issue is in UbiquityMyAdmin as you already figured-out, specifically in this lines:

            ob_end_flush();
        }

It flushes all buffers, including buffer that 'wraps' Ubiquity and serves as an interceptor to send data to RoadRunner and not to the standard output.

Some technical details: Ubiquity does not support PSR-7 for the performance reasons, so the only way to 'intercept' the HTTP output and send it to the RoadRunner is to use buffers. (That's why we need php-cgi, as php discard headers, while php-cgi preserve it). However, if all levels of buffers are flushed, including the wrapper, I can do nothing with that.

I have seen that the fix already present from Ubiquity side. Thank you for your interest and the bug report!