In httpd.conf I have:
在httpd.conf我有:
<Perl>
$MyPackage::foo = { ... };
</Perl>
According to the docs, this should, since it's qualified, persist into my perl scripts, which are run with the modperl handler. And sometimes they do. But then all I need to do is touch MyPackage.pm, and all of the sudden $MyPackage::foo is now undef. Restart the web server, and it works again.
根据文档,由于它是合格的,因此应该保留到我的perl脚本中,这些脚本使用modperl处理程序运行。有时它们会这样做。但接下来我需要做的就是触摸MyPackage.pm,所有突然的$ MyPackage :: foo现在都是undef。重新启动Web服务器,它再次工作。
Anybody have an end to my tears?
有人结束了我的眼泪吗?
My best guess is that the block only gets run once, when the .conf is parsed, and then a new thread picks up the reloaded file. But why doesn't it get run once per thread? Isn't there something I can use besides $ENV and custom directives that gets loaded exactly once per server, and then copied to all interpreters? (I'm probably using the wrong terminology at the end here, but you get the idea.)
我最好的猜测是,当解析.conf时,块只运行一次,然后一个新线程获取重新加载的文件。但为什么每个线程都没有运行一次?除了$ ENV和自定义指令之外,我是否可以使用每个服务器只加载一次,然后复制到所有解释器? (我可能在最后使用了错误的术语,但你明白了。)
1 个解决方案
#1
I figured this out while typing it up, but thought I would share in case it saved anyone else the hairs I just pulled out.
我在打字的过程中想到了这一点,但我想我会分享,以防万一我把刚拔出的头发保存起来。
The easiest solution is to rename the scoped variable in the .conf to something you're not actually using:
最简单的解决方案是将.conf中的作用域变量重命名为您实际未使用的内容:
<Perl>
$MyPackageConfig::foo = { ... };
</Perl>
...and then have your actual package pick it up:
...然后让你的实际包裹拿起来:
package MyPackage;
our $foo = $MyPackageConfig::foo;
This seems to have worked consistently when I tested it.
当我测试它时,这似乎一直有效。
#1
I figured this out while typing it up, but thought I would share in case it saved anyone else the hairs I just pulled out.
我在打字的过程中想到了这一点,但我想我会分享,以防万一我把刚拔出的头发保存起来。
The easiest solution is to rename the scoped variable in the .conf to something you're not actually using:
最简单的解决方案是将.conf中的作用域变量重命名为您实际未使用的内容:
<Perl>
$MyPackageConfig::foo = { ... };
</Perl>
...and then have your actual package pick it up:
...然后让你的实际包裹拿起来:
package MyPackage;
our $foo = $MyPackageConfig::foo;
This seems to have worked consistently when I tested it.
当我测试它时,这似乎一直有效。