Ruby-on-rails 在 webrick 服务器中以生产模式运行 rails

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10926737/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 03:30:31  来源:igfitidea点击:

Running rails on a Production mode in webrick server

ruby-on-railsrubyruby-on-rails-3

提问by Mujahid

In my current ruby on rails project, I am using webrick (default) server for development. I have a separate server for testing the application and I want to set the environment to Products in it. I used the following line to run the server in production mode.

在我当前的 ruby​​ on rails 项目中,我使用 webrick(默认)服务器进行开发。我有一个单独的服务器来测试应用程序,我想将环境设置为其中的产品。我使用以下行在生产模式下运行服务器。

rails s -e production

The issue is, it works perfectly if its in the development mode, but in server mode I'm getting following error:

问题是,如果在开发模式下它可以完美运行,但在服务器模式下我收到以下错误:

Started GET "/" for 172.20.7.94 at Thu Jun 07 10:35:45 +0530 2012
  Processing by FrontendController#dashboard as HTML
Rendered frontend/dashboard.html.erb within layouts/frontend (3.0ms)
Completed 200 OK in 50ms (Views: 22.0ms | ActiveRecord: 0.0ms)


Started GET "/assets/frontend-datauri.css" for 172.20.7.94 at Thu Jun 07 10:35:4
6 +0530 2012
  Processing by Jammit::Controller#package as HTML
  Parameters: {"extension"=>"css", "package"=>"frontend-datauri"}
Completed 500 Internal Server Error in 190ms

NameError (uninitialized constant POpen4::Open4):


Started GET "/assets/frontend.js" for 172.20.7.94 at Thu Jun 07 10:35:46 +0530 2
012
  Processing by Jammit::Controller#package as
  Parameters: {"extension"=>"js", "package"=>"frontend"}
Completed 500 Internal Server Error in 105ms

NameError (uninitialized constant POpen4::Open4):

I am using Jammit and POpen4 and my rails version is: 3.0.9. Ruby version 1.8.7. I can't currently upgrade the version as several other developers are involved in the project. Can anybody give me a solution for this.

我正在使用 Jammit 和 POpen4,我的 rails 版本是:3.0.9。红宝石版本 1.8.7。我目前无法升级版本,因为该项目涉及其他几个开发人员。任何人都可以给我一个解决方案。

Thanks

谢谢

采纳答案by Mujahid

Thanks a lot for everyone who tried to help me regarding this issue. I installed CentOS and everything's have fixed and running smoothly.

非常感谢所有试图帮助我解决这个问题的人。我安装了 CentOS,一切都已修复并顺利运行。

That might be some issue with the Windows server 2008 which I was using previously

这可能是我之前使用的 Windows Server 2008 的一些问题

Thanks a lot

非常感谢

回答by Thomas Guillory

The best practice is to specify your dependencies in your Gemfile.

最佳实践是在 Gemfile 中指定您的依赖项。

Gemfile:

宝石档案:

...
gem 'popen4'
...

and then run bundle installto create a specific bundle of gems for your app.

然后运行bundle install为您的应用程序创建特定的 gem 包。

Otherwise your app relies on what you have installed locally on your machine (I suppose via gem install popen4).

否则,您的应用程序依赖于您在机器上本地安装的内容(我想是通过gem install popen4)。

Here you production machine doesn't have the gem POpen4 installed on it... So the other quick (but no recommended) solution is to install the gem manually on your production machine with gem install popen4.

在这里,您的生产机器上没有安装 gem POpen4 ......所以另一个快速(但不推荐)的解决方案是在您的生产机器上手动安装 gem gem install popen4