Hi,
I'm working on a rest api and try to close the connection and continue the process.
Any idea how I can send \Phalcon\Http\Response () and keep the process alive ?
Thanks
|
May '13 |
4 |
1053 |
2 |
Hi,
I'm working on a rest api and try to close the connection and continue the process.
Any idea how I can send \Phalcon\Http\Response () and keep the process alive ?
Thanks
Well, I think one does not keep a web server request alive because the PHP processes are reused by incoming requests in a standard web server, if you can deploy your own CLI server (note that this does not scale properly and have other flaws) you can simulate sending the HTTP request (headers/body) while keeping the process alive.
Well, I'm using shell exec to avoid that issue but Im looking for something a little bit more "clean". Can the CLI server share some classes from my web server app (phalcon) or share memory with it?.
Basically, it's a rest api. I have to send the response asap then do some heavy processing. I know I have different options to accomplish that but I wanted to see what the phalcon community is going to suggest.
Thanks
I think what you need is a message/queue server, when you process the API response and send a message to the worker, then via cron or a process in background you get the messages from the queue and process the heavy tasks.
http://fr.slideshare.net/IanBarber/zeromq-is-the-answer-php-tek-11-version https://www.google.com/search?q=zeromq+php
Just found these articles about RabbitMQ, they look very clear:
http://www.brandonsavage.net/queuing-with-rabbitmq-and-php/ http://www.brandonsavage.net/publishing-messages-to-rabbitmq-with-php/