开发者

is there a way to just respawn php children processes without restarting php itself?

开发者 https://www.devze.com 2023-03-10 17:12 出处:网络
I\'m running php-fpm and I\'d开发者_如何转开发 like to shutdown and respawn php children without restarting php itself. Actually, there is by using pcntl functions, pcntl_fork() in particular would be

I'm running php-fpm and I'd开发者_如何转开发 like to shutdown and respawn php children without restarting php itself.


Actually, there is by using pcntl functions, pcntl_fork() in particular would be your friend for this..

You can find many code examples on this page.

Trivial example:

$pid = pcntl_fork();

if($pid) {
  // parent process runs what is here
  print "parent\n";
}
else {
  // child process runs what is here
  print "child\n";
}


// outputs:

child
parent

This is as simple as it gets, in real life you have a bit more to check for than this, do look at pcntl section on php.net, and a few of the code examples on the page I posted you. Hope that gets you on the right track, happy coding.

0

精彩评论

暂无评论...
验证码 换一张
取 消