没有Puma的开发模式上的Rails

时间:2016-08-13 23:24:46

标签: ruby-on-rails bundle puma

在我为生产模式安装Puma之后,它不应该在我的本地计算机上运行,​​但是Puma正在开发模式并且在片刻之后停止并且没有错误。

$ rails server
=> Booting Puma
=> Rails 4.2.2 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[8707] Puma starting in cluster mode...
[8707] * Version 3.1.0 (ruby 2.3.0-p0), codename: El Niño Winter Wonderland
[8707] * Min threads: 1, max threads: 6
[8707] * Environment: development
[8707] * Process workers: 1
[8707] * Phased restart available
[8707] * Listening on tcp://localhost:3000
[8707] Use Ctrl-C to stop

看起来像是捆绑问题: github.com/puma/puma/issues/983

1 个答案:

答案 0 :(得分:1)

这不是一个真正的解决方案,但对于那些将服务器用于Puma生产模式并希望使用WEBrick在本地机器开发模式下工作的人来说,这是一个很好的工作。该解决方案基于mrvncaragay的想法

1。 将您Gemfile拆分为3个文件:

Gemfile_base
Gemfile_development
Gemfile_production
Gemfile_base中的

包括所有未测试的gem,开发和&生产。没有理由在{Gemfile_development或Gemfile_production文件中包含source 'https://rubygems.org'。 在Gemfile_development中仅包括test&发展gem 在Gemfile_production中仅包含生产gem s

2。 将Gemfile中的所有行替换为:

source 'https://rubygems.org'

gemfiles = [ 'Gemfile_base', 'Gemfile_development' ]
#gemfiles = [ 'Gemfile_base', 'Gemfile_production' ]
gemfiles.each do |gemfile|
  instance_eval File.read(gemfile)
end

3。 部署到生产服务器

4。 将Gemfile添加到.gitignore文件

#bundle Puma in development mode bad wordaround
Gemfile

5。 来自源代码管理的Untrack Gemfile

git rm --cached Gemfile

6。 从以下位置更改生产服务器中Gemfile的提交行:

source 'https://rubygems.org'

gemfiles = [ 'Gemfile_base', 'Gemfile_development' ]
#gemfiles = [ 'Gemfile_base', 'Gemfile_production' ]
gemfiles.each do |gemfile|
  instance_eval File.read(gemfile)
end

为:

source 'https://rubygems.org'

#gemfiles = [ 'Gemfile_base', 'Gemfile_development' ]
gemfiles = [ 'Gemfile_base', 'Gemfile_production' ]
gemfiles.each do |gemfile|
  instance_eval File.read(gemfile)
end