Comments (28)
The Symfony example is not performant at all. It's doing a $kernel->reboot(null);
after every request. Is that really necessary? Why not just do $kernel->boot();
before the while loop, and then process all the requests without rebooting? Makes it much faster.
from roadrunner.
Wasn't this fixed with resettable services?
from roadrunner.
Done! https://github.com/spiral/roadrunner/wiki/Symfony-Framework Let me know if you want to change something in the article. I wonder if GitHub has any protocol for Wiki PRs.
from roadrunner.
FYI, you can define ENV in env
section of config, these variables would be PHP process specific.
from roadrunner.
Thanks @wolfy-j. Indeed env vars should probably be moved here. I'll send you the changes when ready.
from roadrunner.
@dunglas I was using your config in my SF 4.1 app, but my static files like (app.js and images) could not be loaded. Switched to php -S 0.0.0.0:8000
-t public/ and worked. ยฟDo you have any idea or suggestions for finding the issue?
from roadrunner.
Have you changed static.dir
option to reflect your directory structure?
static:
dir: "public"
forbid: [".php", ".htaccess"]
Also, try to run with -d
flag to see what RR debug log says. Most likely your public directory path is invalid (though you must get an error if the path does not exist).
from roadrunner.
Yeap, the folder is pointing to the right direction and exists. Running with -d
flag shows no output. The error happens at browser level when tries to load the js.
from roadrunner.
Does -d
show any other requests coming to RR?
It should look like that: http://prntscr.com/l1atdz
from roadrunner.
Yeap, and found the assets ones. They are answered with 404s.
from roadrunner.
Yeah, found it. Is passing the requests for files directly to the application.
from roadrunner.
Daaang I'm stupid! The static
config was not properly indented.
Sorry for wasting your time @wolfy-j . I'm loving the project already!! :)
from roadrunner.
This is correct behavior if file not found or static service is disabled (identical to nginx try_files
).
from roadrunner.
Daaang I'm stupid! The
static
config was not properly indented.Sorry for wasting your time @wolfy-j . I'm loving the project already!! :)
Ugh, yaml is really annoying sometimes. Try using json config instead if you run into this problem often. :)
from roadrunner.
I just tried this example, but it doesn't work. I get this error: worker error: invalid prefix (checksum)
This is shown in my PHP error output:
[05-Oct-2018 09:50:32 UTC] PHP Fatal error: Uncaught ErrorException: Warning: unpack(): Type C: not enough input, need 1, have 0 in /var/www/app/vendor/spiral/goridge/php-src/StreamRelay.php:110
Stack trace:
#0 /var/www/app/vendor/spiral/goridge/php-src/StreamRelay.php(76): Spiral\Goridge\StreamRelay->fetchPrefix()
#1 /var/www/app/vendor/spiral/roadrunner/src/Worker.php(51): Spiral\Goridge\StreamRelay->receiveSync(NULL)
#2 /var/www/app/vendor/spiral/roadrunner/src/Worker.php(56): Spiral\RoadRunner\Worker->receive(Array)
#3 /var/www/app/vendor/spiral/roadrunner/src/PSR7Client.php(45): Spiral\RoadRunner\Worker->receive(Array)
#4 /var/www/app/worker.php(51): Spiral\RoadRunner\PSR7Client->acceptRequest()
#5 {main}
thrown in /var/www/app/vendor/spiral/goridge/php-src/StreamRelay.php on line 110
When I change the while loop to this:
while ($req = $psr7->acceptRequest()) {
try {
$resp = new \Zend\Diactoros\Response();
$resp->getBody()->write("hello world");
$psr7->respond($resp);
} catch (\Throwable $e) {
$psr7->getWorker()->error(get_class($e));
$psr7->getWorker()->error((string)$e);
}
}
it works fine.
Something is happening inside $response = $kernel->handle($request);
that breaks.
What am I doing wrong?
from roadrunner.
Do you echo anything to STDOUT without buffers? There is an option how you can debug it.
Switch RR to work over TCP:
workers:
relay: "tcp://localhost:5000"
Use SocketRelay instead of SteamRelay:
$relay = new SocketRelay("localhost", 5000);
from roadrunner.
Weird, now it works. But I don't see anything being echo'd?
DEBU[0000] [rpc]: started
DEBU[0000] [http]: started
INFO[0002] 172.18.0.1 302 GET http://my-domain.eu.ngrok.io/
INFO[0004] 172.18.0.1 302 GET http://my-domain.eu.ngrok.io/
INFO[0009] 172.18.0.1 200 GET http://my-domain.eu.ngrok.io/_profiler/empty/search/results?limit=10
INFO[0013] 172.18.0.1 200 GET http://my-domain.eu.ngrok.io/_profiler/df487a
INFO[0017] 172.18.0.1 200 GET http://my-domain.eu.ngrok.io/cart/1
INFO[0022] 172.18.0.1 200 GET http://my-domain.eu.ngrok.io/cart/1
INFO[0023] 172.18.0.1 200 GET http://my-domain.eu.ngrok.io/cart/1
INFO[0025] 172.18.0.1 302 GET http://my-domain.eu.ngrok.io/_profiler/search?limit=10
INFO[0025] 172.18.0.1 200 GET http://my-domain.eu.ngrok.io/_profiler/d179e9/search/results?ip=&limit=10
INFO[0027] 172.18.0.1 200 GET http://my-domain.eu.ngrok.io/_profiler/d179e9
INFO[0030] 172.18.0.1 200 GET http://my-domain.eu.ngrok.io/_profiler/d179e9?panel=time
from roadrunner.
Well, RR does not redirect STDOUT to the log, only STDERR. Does your worker die during the bootload? If so, try to run it manually php worker.php
and see what it echoes and where.
If you can't find it (or don't want to) switch to TCP or Unix sockets (unix://socket.sock
). It would work just a bit slower than pipes and will allow you to use STDOUT for your own purposes.
from roadrunner.
I started RR and in a new terminal opened php worker.php
but it didn't output anything. It's just waiting... Also tried to move the SF kernel->boot to outside the while loop. No difference.
from roadrunner.
When doing a couple requests, and monitor rr http:workers
it stays up. So the worker doesn't die.
from roadrunner.
So it's not bootloader issues, sounds like you output something to STDOUT while running your script. Is it possible you have some warnings and display_errors
points to STDOUT?
Since it's working over sockets I can conclude that your workers are fine, but they definitely use pipes for something which creates conflicts with Goridge relays.
P.S. Warning: unpack(): Type C: not enough input, need 1, have 0 in /var/www/app/vendor/spiral/goridge/php-src/StreamRelay.php:110
this error is expected if you start your worker manually without properly formatting your data frames.
from roadrunner.
Do you use any header
functions? They will write to STDOUT as well.
from roadrunner.
More info added here: https://github.com/spiral/roadrunner/wiki/PHP-Workers
from roadrunner.
I don't have any header functions in use. Also checked output of headers_list()
and its empty. Is there a way of capturing the output of the php worker.php
file?
from roadrunner.
I'm running this inside Docker btw, not sure if that's related.
from roadrunner.
Problem solved:
env(LOG_STREAM): 'php://stdout'
Sorry everybody!
from roadrunner.
Yes it is, some Symfony services are stateful. You must reset their states before handling a different requests to avoid side effects.
from roadrunner.
PM has a lot of reseting going on: https://github.com/php-pm/php-pm-httpkernel/blob/master/Bootstraps/Symfony.php
With reset tag in symfony now, this should be a lot smaller.
from roadrunner.
Related Issues (20)
- [๐ BUG]: Region is missing from SQS endpoint URL when RR is running inside EC2 HOT 9
- [๐งน CHORE]: Rewrite multipart text values parsing algorithm
- [๐ BUG]: HTTP Queue gets too large HOT 16
- [๐ BUG]: Response status 200 instead of 500 in debug mode if php code fails HOT 4
- [๐ก FEATURE REQUEST]: Use Opentelemerty specific environment variables HOT 5
- [๐ BUG]: rabbitmq_redial error causes redial/retry logic to prematurely exit HOT 14
- [๐ก FEATURE REQUEST]: Log elapsed time always in microseconds HOT 9
- [๐ BUG]: RR cannot parse larger multipart form data HOT 6
- [๐ BUG]: unknown flag for long config options HOT 2
- [๐ BUG]: File uploads exceeding "upload_max_filesize" do not have the proper error code HOT 8
- [๐ก FEATURE REQUEST]: Temporal plugin healthcheck
- [๐ก FEATURE REQUEST]: `musl` arm64 binary `[blocked by GitHub ARM action runners]` HOT 4
- [๐ก FEATURE REQUEST]: RPC call to return all available storages HOT 4
- [๐ก FEATURE REQUEST]: Temporal: Provide some `sugar` for users to set the `Authorization` header
- [๐ BUG]: !BADKEY error on service name with dot (.) HOT 5
- [๐ก FEATURE REQUEST]: Including grpc error details in log messages
- [๐ BUG]: panic in http plugin HOT 5
- [๐ก FEATURE REQUEST]: Add support for streaming RPCs HOT 1
- [๐ BUG]: Incorrect name of the default AMQP exchange (should be 'amq.default') HOT 5
- [๐ BUG]: rr workers/reset commands don't respect default config values HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from roadrunner.