How do I have mod_perl reload source files on change?

流过昼夜 提交于 2019-12-22 05:13:50

问题


I am developing an application with mod_perl and restarting the server every time I change code is a huge drag. I'd like to still use mod_perl for development because it's what I plan on using for the live server. I didn't see anything in the documentation about how to do this.

Thoughts?


回答1:


I think Apache2::Reload will somewhat accomplish what you're looking for. However, remember to delete all this implementation once you're ready to put the app in production.

Monitor All Modules in %INC

To monitor and reload all modules in %INC at the beginning of request's processing, simply add the following configuration to your httpd.conf:

PerlModule Apache2::Reload
PerlInitHandler Apache2::Reload

When working with connection filters and protocol modules Apache2::Reload should be invoked in the pre_connection stage:

PerlPreConnectionHandler Apache2::Reload

Register Modules Implicitly

To only reload modules that have registered with Apache2::Reload, add the following to the httpd.conf:

PerlModule Apache2::Reload
PerlInitHandler Apache2::Reload
PerlSetVar ReloadAll Off
# ReloadAll defaults to On

Then any modules with the line:

use Apache2::Reload;

Will be reloaded when they change.

For for information check out this documentation page. Hope this helps.




回答2:


I use this solution, from Perrin Harkins via PerlMonks:

Set MaxRequestsPerChild to 1, then load any potentially-changing modules in the child, not the parent (obviously only for development environments). Each request will hit a fresh child server, which will load all of your potentially-changing modules anew.

From "A better way to see module changes in a running web server"



来源:https://stackoverflow.com/questions/442166/how-do-i-have-mod-perl-reload-source-files-on-change

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!