在mod_perl2下分叉是一个坏主意吗? [英] Is it a bad idea to fork under mod_perl2?

查看:62
本文介绍了在mod_perl2下分叉是一个坏主意吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在mod_perl2下是否有任何禁忌迹象?应该使用另一种方式在mod_perl2下运行后台进程吗?

Are there any counterindications to fork under mod_perl2? Should one use another way to run background process under mod_perl2?

推荐答案

我通常使用清理处理程序来运行HTTP请求完成后需要执行的所有操作:

I usually use a cleanup handler to run anything that needs to happen after the HTTP request is complete:

$r->push_handlers( PerlCleanupHandler => sub { print "I'm doing stuff!" } );

如果您确实需要执行fork,则不应该以常规方式进行,因为您的派生进程将干扰Apache所需的各种资源,例如文件描述符和套接字,并且很难正确处理所有这些问题. .相反,请尝试 Apache2 :: SubProcess .

If you really need to do a fork, you shouldn't do it the regular way, because your forked process will interfere with various resources that Apache needs, like file descriptors and sockets, and it's very hard to handle all this correctly. Instead, try out Apache2::SubProcess.

这篇关于在mod_perl2下分叉是一个坏主意吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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