PHP service/daemon with asynch calls
Moderator: General Moderators
PHP service/daemon with asynch calls
Hi
I'd like to have a PHP service/daemon running - to which I can forward asynchronous calls. Basically I need to call to start work on something, but not wait for the work to complete before returning.
What's the best way to approach this?
Thanks
Jagin
I'd like to have a PHP service/daemon running - to which I can forward asynchronous calls. Basically I need to call to start work on something, but not wait for the work to complete before returning.
What's the best way to approach this?
Thanks
Jagin
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
Forking. Not exactly sure how it works, but that's how you'd get asynchronous stuff. Can't fiddle with it on my machine since I'm on Windows and that's pcntl_*
Edit Here's a link: Process Control Functions. Surprisingly, it does allow daemonizing a process! You would...
Edit Here's a link: Process Control Functions. Surprisingly, it does allow daemonizing a process! You would...
Code: Select all
if (pcntl_fork()) {
exit;
}
pcntl_setsid();
if (pcntl_fork()) {
exit;
}
// process is now daemonized
Last edited by Ambush Commander on Sun May 28, 2006 9:46 am, edited 1 time in total.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Thanks
Thanks for all the replies.
Found this interesting write-up on a request for multithreading support in PHP (denied for the 1,000th time):
http://www.zend.com/zend/week/week266.php#Heading5
I think I'll go with Mono to write the daemon.
Jagin
Found this interesting write-up on a request for multithreading support in PHP (denied for the 1,000th time):
http://www.zend.com/zend/week/week266.php#Heading5
I think I'll go with Mono to write the daemon.
Jagin
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Thanks
For good reason as I understand the issue because it forces a lot of other language decisions that would make PHP more like general purpose languages like Java, C#, etc.Jagin wrote:Found this interesting write-up on a request for multithreading support in PHP (denied for the 1,000th time):
http://www.zend.com/zend/week/week266.php#Heading5
That sounds like a good decision -- mainly because you really need a different style of garbage collector for long running processes than PHP provides. PHP is optimized for web request processing.Jagin wrote:I think I'll go with Mono to write the daemon.
(#10850)