免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3553 | 回复: 2
打印 上一主题 下一主题

Catalyst Nginx 在web应用中如何协作 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2014-03-20 21:16 |只看该作者 |倒序浏览
   Catalyst 内置了web服务器,看来使用Nginx作为生产环境的Web服务器比较好,一直没有搞清楚两者如何结合?
   
   看了一些资料,感觉Nginx通过配置和一个fastcgi后台运行的守护进程进行交互,由这个守护进程和catalyst框架通讯实现。

   还有一个疑问,如果我的前端使用dojo toolkit,这个框架直接在那些tt2文件中使用就可以了。看起来简单,但是整体的各个组件如何相互协作需要搞清楚?

   我咨询了Catalyst的作者,他是这样回答的:
  Catalyst, unlike a framework like say Ruby on Rails, sits at the center of a number of other Perl technologies.  You named a few, such as Plack/PSGI, Template Toolkit, etc.  Others might include DBIx::Class for interfacing with a database.  And of course any number of testing tools on the Test::* namespace.  As a result you have to put together a stack that makes sense to you, although one of the more common ones would be those mentioned.

Plack is an implementation of the PSGI specification, which connections a web application (such as Catalyst) to a web server, such as Nginx, Apache, Starman, etc.  This glue layer is reusable across many web frameworks, so we all work on it together for the betterment of all.  Plack also implements common middleware for concerns that are cross cutting, such as session and cookie management, authentication, etc.  Some web frameworks make heavy use of middleware, such as Web::Simple, while Catalyst tends to mix and match between middleware and pre-existing Catalyst specific components.  For example, Catalyst has its own mature session and authentication components, so we tend to use that rather than the Plack middleware (although over time I'd personally like to move towards using more middleware).

Template Toolkit (TT) is a templating system which is a common choice for a View layer in Catalyst.  It allows you a more cleanly expressive approach to the concern of how your web pages look.  Quite often you will use a Javascript framework, such as Dojo, Jquery or Angular.js to name a few of the ones I am personally familiar with.  Javascript will be integrated into the View (TT).  Catalyst, unlike some web frameworks, doesn't offer a lot of Javascript code generation tools since most Perl programmers prefer a more hands on approach and write their Javascript manually.  Catalyst offers some tools for interacting with a Javascript application, such as support for JSON.  So using Javascript with Catalyst is totally fine, just as I said compared to some frameworks you might find yourself needing to write a bit more manual code.  As I said, Perl programmers tend to like to be 'close to the metal' so that is reflected in how Catalyst works.

I recommend you look at a few Catalyst applications on Github and review the tutorial if you can.  

  FastCGI is great, and my first choice for production systems.  Plack implements PSGI and offers you a way to integrate a server such as FastCGI with your Catalyst web application.  It also lets you 'glue' that same application to a different server.  For example, many people use Starman as a server for development be cause its very easy to setup, but use something else in production (although Starman if run behind a proxy can be solid in production as well and some people choose that setup).

[client web browser] <--> [Apache <--> FastCGI] <--> [Plack FastCGI Handler <--> Catalyst <--> DBIx::Class <--> Database]

^^ is one example stack.  

Here's a great blog of someone that started with Catalyst from the start and he did his best to record the journey.  Maybe it will help you.

http://blogs.perl.org/users/j0e/

Also, I recommend reading the current and past Advent Calendars:

http://www.catalystframework.org/calendar/

   You are welcome!

Best of luck! --jnap

   欢迎指导!

论坛徽章:
0
2 [报告]
发表于 2014-03-22 08:16 |只看该作者
这个Catalyst难道就没有人使用吗?

论坛徽章:
0
3 [报告]
发表于 2014-03-22 11:39 |只看该作者
nginx+fastcgi+catalyst,catalyst 使用 template toolkit 做前端模板, DBIX::Class 做数据库,我是这样的。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP