如何设计用于持久PHP FastCGI进程应用程序? [英] How to design applications for persistent PHP FastCGI processes?

查看:119
本文介绍了如何设计用于持久PHP FastCGI进程应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PHP是最后开始得到 TRUE 的FastCGI实现的。 (不要与常用的启动脚本PHP-FPM或 PHP程序混淆nginx的 - 想想的node.js 的PHP

PHP is finally starting to get TRUE FastCGI implementations. (Not to be confused with PHP-FPM or PHP process startup scripts commonly used with Nginx - think node.js for PHP.

你如何使用这些新的异步模式的开放设计的应用程序?

How do you design applications with these new, asynchronous patterns opening up?

例如,通常如果有错误或异常的日志应用它,提醒用户,死了()的。但是,如果你有一个(几乎)永无止境的守护进程运行的话,你如何结束,而当前请求,并移动到下一个处理错误?你不能只是继续与你在做(因为错误的)什么 - 但你不能没有杀死进程退出

For example, usually if there is an error or exception the app logs it, alerts the user, and die()'s. However, if you have a (almost) never-ending daemon running then how do you handle errors while ending the current request and moving to the next? You can't just continue with what you were doing (because of the error) - yet you can't exit without killing the process.

推荐答案

例如...

while(1) {
   try {
      something();
   catch (Exception) {
      log();
   }
}

你可以把东西中三页code的()。如果错误在code的任何地方发生,你可以简单地跳到循环的下一个迭代而不是继续与当前迭代的。

you could put three pages of code in something(). if an error happens anywhere in that code, you could simply skip to the next iteration of the loop instead of continuing on with the current iteration.

这篇关于如何设计用于持久PHP FastCGI进程应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆