精华帖 (0) :: 良好帖 (17) :: 新手帖 (5) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2011-09-01
最后修改:2011-09-01
I have question about the dispatch.fcgi file, why we need to create this file on rails3, i remember someone said that the rack includes the cgi,
So, the rails3 base on rack , we haven't to configure file dispatch.fcgi, rather configure the config.ru for rack, isn't it ? Sorry, my linux system has not output language of Chinese. |
|
返回顶楼 | |
发表时间:2011-09-02
最后修改:2011-09-02
coolesting 写道 I have question about the dispatch.fcgi file, why we need to create this file on rails3, i remember someone said that the rack includes the cgi,
So, the rails3 base on rack , we haven't to configure file dispatch.fcgi, rather configure the config.ru for rack, isn't it ? Sorry, my linux system has not output language of Chinese. Rack确实有对CGI和FastCGI的支持: class Rack::Handler::CGI class Rack::Handler::EventedMongrel class Rack::Handler::FastCGI class Rack::Handler::LSWS class Rack::Handler::Mongrel class Rack::Handler::SCGI class Rack::Handler::SwiftipliedMongrel class Rack::Handler::Thin class Rack::Handler::WEBrick 但是config.ru里,是直接run SomeApp::Application的 如果用rackup config.ru(或者bundle exec rackup config.ru)运行的话,会发现和rails server一样用的是WEBrick,而单独写的dispatch.fcgi,是用 Rack::Handler::FastCGI.run Rack::PathInfoRewriter.new(SomeApp::Application) 这里的Rack::PathInfoRewriter是我们自己定义的,用来设置环境变量里的PATH_INFO和QUERY_STRING,对于Handler本身,用的也是Rack::Handler::FastCGI.run而不是config.ru里的Rack::Handler::WEBrick.run 也就是说,单独建立一个dispatch.fcgi的目的在于用一个FastCGI的Handler,并且设置PATH_INFO等环境变量,而rails自动生成的config.ru默认是没有这些的,当然改成这样子也是一样的了 |
|
返回顶楼 | |
发表时间:2011-09-02
最后修改:2011-09-02
stfairy 写道 .......................................... 略 Rack确实有对CGI和FastCGI的支持: .......................................... 略 也就是说,单独建立一个dispatch.fcgi的目的在于用一个FastCGI的Handler,并且设置PATH_INFO等环境变量,而rails自动生成的config.ru默认是没有这些的,当然改成这样子也是一样的了 嗯,如你所说, 但有几个问题, 1. 那么rails3, 在创建应用时没有这个文件呢? 在官方的文档也找不到什么说明. 2. 用内置WEBrick时, 为什么直接由rackup从config.ru启动呢? 莫非rackup里设置好了。 3. 为什么lighttpd配置里有个Enterprise-Wiki-fcgi.socket文件, rails没自带这文件,从那里来的呢? |
|
返回顶楼 | |
发表时间:2011-09-03
coolesting 写道 stfairy 写道 .......................................... 略 Rack确实有对CGI和FastCGI的支持: .......................................... 略 也就是说,单独建立一个dispatch.fcgi的目的在于用一个FastCGI的Handler,并且设置PATH_INFO等环境变量,而rails自动生成的config.ru默认是没有这些的,当然改成这样子也是一样的了 嗯,如你所说, 但有几个问题, 1. 那么rails3, 在创建应用时没有这个文件呢? 在官方的文档也找不到什么说明. 2. 用内置WEBrick时, 为什么直接由rackup从config.ru启动呢? 莫非rackup里设置好了。 3. 为什么lighttpd配置里有个Enterprise-Wiki-fcgi.socket文件, rails没自带这文件,从那里来的呢? 1. Rails 3以后preferred deployment tool是Passenger之类的了,FastCGI并非首选,即使在之前的版本,绝大多数书籍和资料也都是用Mongrel的,所以这个文件没有什么记载 2. top-level的run,指的就是Rack::Handler::WEBrick.run 3. 这个文件并不存在,只要指定一个文件名,在LightTPD与FastCGI连接后会创建这个文件并使用它进行交互 |
|
返回顶楼 | |
发表时间:2011-09-03
谢谢, 楼主你的解释,
开始我一直很迷惑, rails 3 没有dispatch.fcgi的原因, 的确初期的rails开发考虑到各种服务器, 都配置了这个文件, 甚至官方默认首推是lighttpd服务器。 当我读完heroku和github上的文档, 发现rails 3+ 后来推荐使用的是服务器是thin, 它对ruby和rack应用整合得非常好了, 我推断heroku也是nginx+thin的部署, 所以每次都只配置一下config.ru这个文件就可以直接运行。 |
|
返回顶楼 | |
发表时间:2011-09-03
coolesting 写道 谢谢, 楼主你的解释,
开始我一直很迷惑, rails 3 没有dispatch.fcgi的原因, 的确初期的rails开发考虑到各种服务器, 都配置了这个文件, 甚至官方默认首推是lighttpd服务器。 当我读完heroku和github上的文档, 发现rails 3+ 后来推荐使用的是服务器是thin, 它对ruby和rack应用整合得非常好了, 我推断heroku也是nginx+thin的部署, 所以每次都只配置一下config.ru这个文件就可以直接运行。 嗯,Thin的确是一个好的选择,比较轻量,不过我现在在生产环境部署的两台机器分别是用Passenger和FastCGI的,不知道这三者性能上到底有那些差别 |
|
返回顶楼 | |
发表时间:2011-09-27
LZ,我是部分参照你的配置进行的,还有一部分是参照了robbin的早期的配置,把lighttpd的启动放在了/etc/init.d/里面,其他都是类似的,解决了一些权限的问题后,启动light:/etc/init.d/lighttpd start,这个是OK,但是stop却是failed,查看了下log:
2011-09-27 10:51:49: (log.c.166) server started 2011-09-27 10:51:49: (mod_fastcgi.c.1103) the fastcgi backend /root/weeklyreport/public/dispatch.fcgi failed to start: 2011-09-27 10:51:49: (mod_fastcgi.c.1107) child exited with status 13 /root/weeklyreport/public/dispatch.fcgi 2011-09-27 10:51:49: (mod_fastcgi.c.1110) If you're trying to run your app as a FastCGI backend, make sure you're using the FastCGI-enabled version. If this is PHP on Gentoo, add 'fastcgi' to the USE flags. 2011-09-27 10:51:49: (mod_fastcgi.c.1397) [ERROR]: spawning fcgi failed. 2011-09-27 10:51:49: (server.c.945) Configuration of plugins failed. Going down. 麻烦LZ帮我看下是出了什么问题。 其他小问题都自己摸索着解决了,但这个我完全找不到方向去解决 ,,, |
|
返回顶楼 | |
发表时间:2011-09-28
乌龙饭 写道 LZ,我是部分参照你的配置进行的,还有一部分是参照了robbin的早期的配置,把lighttpd的启动放在了/etc/init.d/里面,其他都是类似的,解决了一些权限的问题后,启动light:/etc/init.d/lighttpd start,这个是OK,但是stop却是failed,查看了下log:
2011-09-27 10:51:49: (log.c.166) server started 2011-09-27 10:51:49: (mod_fastcgi.c.1103) the fastcgi backend /root/weeklyreport/public/dispatch.fcgi failed to start: 2011-09-27 10:51:49: (mod_fastcgi.c.1107) child exited with status 13 /root/weeklyreport/public/dispatch.fcgi 2011-09-27 10:51:49: (mod_fastcgi.c.1110) If you're trying to run your app as a FastCGI backend, make sure you're using the FastCGI-enabled version. If this is PHP on Gentoo, add 'fastcgi' to the USE flags. 2011-09-27 10:51:49: (mod_fastcgi.c.1397) [ERROR]: spawning fcgi failed. 2011-09-27 10:51:49: (server.c.945) Configuration of plugins failed. Going down. 麻烦LZ帮我看下是出了什么问题。 其他小问题都自己摸索着解决了,但这个我完全找不到方向去解决 ,,, 你在lighttpd里配置fastcgi的配置文件是怎样的? |
|
返回顶楼 | |
发表时间:2011-09-28
谢谢你给我答复,昨天我又重新弄了一遍, 是完全按照你的步骤来的,可是还是不行,
lighttpd里面的fastcgi配置也是你给出来的照样写的, 这次我先尝试着执行./dispatch.fcgi,没有任何输出。 然后./lighttpd.sh start以后没有起的来。log中,错误换了一个status: 2011-09-29 06:10:31: (log.c.166) server started 2011-09-29 06:10:31: (mod_fastcgi.c.1103) the fastcgi-backend /home/xuminke/rails_deploy/lighttpd/www/home/xuminke/weeklyreport/public/dispatch.fcgi failed to start: 2011-09-29 06:10:31: (mod_fastcgi.c.1107) child exited with status 2 /home/xuminke/rails_deploy/lighttpd/www/home/xuminke/weeklyreport/public/dispatch.fcgi 2011-09-29 06:10:31: (mod_fastcgi.c.1110) If you're trying to run your app as a FastCGI backend, make sure you're using the FastCGI-enabled version. If this is PHP on Gentoo, add 'fastcgi' to the USE flags. 2011-09-29 06:10:31: (mod_fastcgi.c.1397) [ERROR]: spawning fcgi failed. 2011-09-29 06:10:31: (server.c.945) Configuration of plugins failed. Going down. 哦,我用的是radhat...lighttpd配置好以后已经可以访问www/htdocs/index.html 页面,估计fcgi有问题 vim config/conf.d/fastcgi.conf:修改如下 $HTTP["host"] == "localhost" { server.document-root = server_root + "/home/xuminke/weeklyreport/public" server.error-handler-404 = "/dispatch.fcgi" server.dir-listing = "disable" fastcgi.server = ( ".fcgi" => ("localhost" => ( "min-procs" => 1, "max-procs" => 5, "socket" => socket_dir + "/weeklyreport-fcgi.socket", "bin-path" => server_root + "/home/xuminke/weeklyreport/public/dispatch.fcgi", "bin-environment" => ( "RAILS_ENV" => "production", "TMP" => "/home/xuminke/weeklyreport/tmp", ), ) ) ) } 希望您能帮我分析分析到底是哪边配置的不对,,,,哎。rails3的部署用fcgi真是太麻烦了。。。 还有一个疑问,按照您的步骤安装fcgi的ruby支持库,怎么不会在gemlist里面显示?难道这样装不是一个gem? 另外在module.conf里面是否只要去掉下面总共5行的注释?(一行mod_rewrite,4个include): server.modules = ( "mod_access", # "mod_alias", # "mod_auth", # "mod_evasive", # "mod_redirect", "mod_rewrite", # "mod_setenv", # "mod_usertrack", ) # uncomment the following lines include "conf.d/fastcgi.conf" include "conf.d/simple_vhost.conf" include "conf.d/cgi.conf" include "conf.d/compress.conf" |
|
返回顶楼 | |
发表时间:2011-09-30
看了你的配置,觉得没有什么问题
如果这样的话不成功,建议你使用Passenger,我在production mode下已经用Passenger部署了一台,跑了一个多月,压力测试2小时50万PV一点问题没有,稳定的平均日PV在1万,还没有看到任何性能上的问题,而且也很方便 乌龙饭 写道 谢谢你给我答复,昨天我又重新弄了一遍, 是完全按照你的步骤来的,可是还是不行,
lighttpd里面的fastcgi配置也是你给出来的照样写的, 这次我先尝试着执行./dispatch.fcgi,没有任何输出。 然后./lighttpd.sh start以后没有起的来。log中,错误换了一个status: 2011-09-29 06:10:31: (log.c.166) server started 2011-09-29 06:10:31: (mod_fastcgi.c.1103) the fastcgi-backend /home/xuminke/rails_deploy/lighttpd/www/home/xuminke/weeklyreport/public/dispatch.fcgi failed to start: 2011-09-29 06:10:31: (mod_fastcgi.c.1107) child exited with status 2 /home/xuminke/rails_deploy/lighttpd/www/home/xuminke/weeklyreport/public/dispatch.fcgi 2011-09-29 06:10:31: (mod_fastcgi.c.1110) If you're trying to run your app as a FastCGI backend, make sure you're using the FastCGI-enabled version. If this is PHP on Gentoo, add 'fastcgi' to the USE flags. 2011-09-29 06:10:31: (mod_fastcgi.c.1397) [ERROR]: spawning fcgi failed. 2011-09-29 06:10:31: (server.c.945) Configuration of plugins failed. Going down. 哦,我用的是radhat...lighttpd配置好以后已经可以访问www/htdocs/index.html 页面,估计fcgi有问题 vim config/conf.d/fastcgi.conf:修改如下 $HTTP["host"] == "localhost" { server.document-root = server_root + "/home/xuminke/weeklyreport/public" server.error-handler-404 = "/dispatch.fcgi" server.dir-listing = "disable" fastcgi.server = ( ".fcgi" => ("localhost" => ( "min-procs" => 1, "max-procs" => 5, "socket" => socket_dir + "/weeklyreport-fcgi.socket", "bin-path" => server_root + "/home/xuminke/weeklyreport/public/dispatch.fcgi", "bin-environment" => ( "RAILS_ENV" => "production", "TMP" => "/home/xuminke/weeklyreport/tmp", ), ) ) ) } 希望您能帮我分析分析到底是哪边配置的不对,,,,哎。rails3的部署用fcgi真是太麻烦了。。。 还有一个疑问,按照您的步骤安装fcgi的ruby支持库,怎么不会在gemlist里面显示?难道这样装不是一个gem? 另外在module.conf里面是否只要去掉下面总共5行的注释?(一行mod_rewrite,4个include): server.modules = ( "mod_access", # "mod_alias", # "mod_auth", # "mod_evasive", # "mod_redirect", "mod_rewrite", # "mod_setenv", # "mod_usertrack", ) # uncomment the following lines include "conf.d/fastcgi.conf" include "conf.d/simple_vhost.conf" include "conf.d/cgi.conf" include "conf.d/compress.conf" |
|
返回顶楼 | |