简体   繁体   English

如何在不重启的情况下在 Apache 中部署 PSGI 脚本?

[英]How do you deploy a PSGI script in Apache without restarting?

I want to deploy a PSGI scripts that runs in Apache2 with Plack.我想用 Plack 部署一个在 Apache2 中运行的 PSGI 脚本。 Apache is configured with: Apache 配置有:

<Location "/mypath">
  SetHandler perl-script
  PerlResponseHandler Plack::Handler::Apache2
  PerlSetVar psgi_app  /path/to/my/script.psgi
</Location>

When I test the script with plackup, the --reload parameter watches updates on the .psgi file.当我使用 plackup 测试脚本时,--reload 参数会.psgi --reload上的更新。 In the production environment it is fine that Apache and Plack do not check and restart on each change for performance reasons, but how can I tell them explicitly to restart Plack::Handler::Apache2 and/or the PSGI script to deploy a new version?在生产环境中,出于性能原因,Apache 和 Plack 不会检查并重新启动每次更改,但我如何明确告诉他们重新启动Plack::Handler::Apache2和/或 PSGI 脚本以部署新版本?

It looks like Plack regularly checks for some changes but I have no clue when.看起来 Plack 会定期检查一些变化,但我不知道什么时候。 Moreover it seems to create multiple instances, so I sometimes get different versions of script.psgi when at /mypath .此外,它似乎创建了多个实例,所以有时我在/mypath时会得到不同版本的script.psgi It would be helpful to manually flush perl response handler without having to restart Apache or to wait for an unknown amount of time.手动刷新 perl 响应处理程序会很有帮助,而无需重新启动 Apache 或等待未知的时间。

The short answer is you can't.简短的回答是你不能。 That's why we recommend you to use plackup (with -r) for quick development and use Apache only for deployment (production use).这就是为什么我们建议您使用 plackup(带 -r)进行快速开发,并将 Apache 仅用于部署(生产使用)。

The other option is have a development apache process, and set MaxRequestsPerChild to a really small value, so that you will get a fresh child spawned in a very short period of time.另一种选择是开发 apache 进程,并将 MaxRequestsPerChild 设置为非常小的值,这样您就可以在很短的时间内生成一个新的孩子。 I haven't tested this, and doing so will definitely impact the performance of your entire httpd, if you run the non-development application running on the same process (which is a bad idea in the first place anyway).我没有对此进行测试,如果您运行在同一进程上运行的非开发应用程序,这样做肯定会影响整个 httpd 的性能(无论如何这首先是个坏主意)。

You can move your application out of the appache process, eg您可以将您的应用程序移出 appache 进程,例如

FastCgiExternalServer /virtual/filename/fcgi -socket /path/to/my/socket

an run your programm with运行你的程序

plackup -s FCGI --listen /path/to/my/socket --nproc 10 /path/to/my/script.psgi

This way you can restart your application without restarting apache.这样您就可以在不重新启动 apache 的情况下重新启动应用程序。

if you save the pid of the main fcgi process (--pid $pid_file) you can easyly restart an load your new code.如果您保存主 fcgi 进程的 pid (--pid $pid_file),您可以轻松地重新启动加载新代码。

There is also a module avail to manage (start,stop, restart) all your fcgi pools: https://metacpan.org/pod/FCGI::Engine::Manager::Server::Plackup (not tested)还有一个模块可用于管理(启动、停止、重新启动)所有 fcgi 池: https://metacpan.org/pod/FCGI::Engine::Manager::Server::Plackup (未测试)

Apache2::Reload (untested) Apache2::重新加载(未经测试)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在dotcloud上使用psgi部署bugzilla? - How to deploy bugzilla with psgi on dotcloud? 如何在不重新启动的情况下调试mod_perl2模块? - How do you debug a mod_perl2 module without restarting? Perl-Starman(PSGI)+ PHP = Apache2代理设置? - 怎么做? - Perl-Starman (PSGI) + PHP = Apache2 proxy setup? - How to do? 我如何在dotcloud上运行简单的perl脚本,即不是psgi标准 - How do I run simple perl script on dotcloud, i.e. not psgi standard 如何在不重新启动Perl调试器中的脚本的情况下重新运行子例程? - How do I rerun a subroutine without restarting the script in Perl's debugger? 您如何在AnyEvent回调中“睡眠”而不暂停整个脚本? - How do you “sleep” in an AnyEvent callback without pausing the whole script? 在apache中将cgi部署到psgi转换的应用程序 - deploying cgi to psgi converted application in apache 如何将静态CGI样式的perl脚本(xxx.pl)转换为动态PSGI应用程序? - How to turn a static CGI-style perl script(xxx.pl) to a dynamic PSGI application? 如何使PSGI程序每个进程只进行一次昂贵的初始化,而不是每个线程? - How do I make a PSGI program do costly initialisation only once per process, not per thread? 如何获得Test :: WWW :: Mechanize :: PSGI对象的“干净”克隆以进行汇总测试? - How do I get a “clean” clone of a Test::WWW::Mechanize::PSGI object for aggregated tests?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM