如何为不同的服务器配置 Catalyst 应用程序?
我正在计划一个 Catalyst 应用程序,它将部署在许多服务器上。它将由支持人员在内部使用来控制在这些服务器上运行的操作系统的各个方面。
除了有限数量的站点特定行为之外,应用程序将在每台服务器上以大致相同的方式运行。某些操作仅适用于某些服务器,而某些操作在其他服务器上的行为会有所不同。
是否有任何公认的设计模式/实践可以实现 Catalyst 应用程序的特定于站点的定制?
我目前正在考虑与应用程序一起部署站点配置文件,该文件将用于确定要启用的操作,并设置控制其他操作行为的参数。理想情况下,这种定制会在 mod_perl (Apache2) 加载应用程序时发生 - 但我不确定这是否可能。
欢迎任何建议!
I am planning a Catalyst application, that will be deployed over a number of servers. It will be used internally by support staff to control aspects of an operational system that runs on those servers.
The application will run much in the same way on each server, save for a limited amount of site specific behaviours. Some actions will only apply to some servers, and some actions will behave differently on other servers.
Are there any recognized design patterns/practices that enable site-specific customization of a Catalyst application?
I am currently thinking of deploying a site configuration file alongside the application, that will be used to determine what actions to enable, and set parameters that control other action's behaviour. Ideally this customization would happen when the application is loaded by mod_perl (Apache2) - but I am not sure if that would even be possible.
Any suggestions welcome!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Catalyst::Plugin::ConfigLoader 的代码可帮助您以
MYAPP_CONFIG_LOCAL_SUFFIX
环境变量的形式进行特定于站点的配置。由于控制器是组件,并且配置在setup_components
时可用,因此在编译控制器时,您可以通过操作注册做任何您想做的蠢事。由于每个人的要求都不同,所以没有太多预先准备的内容,但这并不是特别困难,并且可以在邮件列表中找到建议。Catalyst::Plugin::ConfigLoader has code to help you with site-specific configuration in the form of the
MYAPP_CONFIG_LOCAL_SUFFIX
environment variable. Since Controllers are Components and config is available atsetup_components
time, you can do whatever foolery you want with action registration when your controller is compiled. There's not much pre-rolled for it, because everyone's requirements are so different, but it's not exceptionally hard, and there's advice to be found on the mailing list.您可以设置模板,或根据
$c->req->host
的值在控制器中设置条件行为。You can set templates, or have conditional behaviour in the controllers based on the value of
$c->req->host
.我总是使用
$HOSTNAME
和$USER
的独特组合来定义要加载的特定配置文件,例如I always use the unique combination of
$HOSTNAME
and$USER
to define the specific configuration file to be loaded, e.g.