7

在使用 RVM Ruby 1.9.3-p194 将一个非常基本的 Rails 3.2.3 试用站点部署到“生产”服务器(不是真正投入生产,谢天谢地!)后,我发现以下列出的命令是正确的:

╔══════════════════════════════════════╤═══╗
║ command issued                       │OK?║
╟──────────────────────────────────────┼───╢
║ bundle exec rails console            │ N ║
║ bundle exec rails console production │ Y ║
║ bundle exec rails server             │ Y ║
║ bundle exec rails server production  │ N ║
╚══════════════════════════════════════╧═══╝

我的第一个问题:这是预期的吗?(我原以为右栏中的模式应该是 NYNY。)

更多信息:由于服务器上未安装sqlite3bundle exec rails console gem的可理解原因而失败。但是,失败的痕迹更难理解:bundle exec rails server production

$ bundle exec rails server production
Exiting
/home/spkspike/www/spike.sampablokuper.com/releases/20120530134819/vendor/ruby/1.9.1/gems/rack-1.4.1/lib/rack/handler.rb:63:in `require': cannot load such file -- rack/handler/production (LoadError)
from /home/spkspike/www/spike.sampablokuper.com/releases/20120530134819/vendor/ruby/1.9.1/gems/rack-1.4.1/lib/rack/handler.rb:63:in `try_require'
from /home/spkspike/www/spike.sampablokuper.com/releases/20120530134819/vendor/ruby/1.9.1/gems/rack-1.4.1/lib/rack/handler.rb:16:in `get'
from /home/spkspike/www/spike.sampablokuper.com/releases/20120530134819/vendor/ruby/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:269:in `server'
from /home/spkspike/www/spike.sampablokuper.com/releases/20120530134819/vendor/ruby/1.9.1/gems/railties-3.2.3/lib/rails/commands/server.rb:59:in `start'
from /home/spkspike/www/spike.sampablokuper.com/releases/20120530134819/vendor/ruby/1.9.1/gems/railties-3.2.3/lib/rails/commands.rb:55:in `block in <top (required)>'
from /home/spkspike/www/spike.sampablokuper.com/releases/20120530134819/vendor/ruby/1.9.1/gems/railties-3.2.3/lib/rails/commands.rb:50:in `tap'
from /home/spkspike/www/spike.sampablokuper.com/releases/20120530134819/vendor/ruby/1.9.1/gems/railties-3.2.3/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

我的第二个问题:如何最好地解决这个错误?

4

2 回答 2

18

您不想使用生产环境以生产模式启动服务器吗?

rails server -e production

rails 控制台环境和 rails server -e 环境的语法差异有点像 PITA

于 2012-05-30T14:22:37.287 回答
3

在控制台生产的情况下指定环境,在服务器的情况下它指定其他东西(可能使用哪个服务器 webrick/...)。

因此,如果您想指定环境,请执行以下操作:

ENV=production rails server
于 2012-05-30T14:06:57.223 回答