2016-08-13 138 views
1

当我为生产模式安装Puma后,它不应该在我的本地机器上运行,但是Puma在开发模式下启动并且在没有错误之后停止。Rails开发模式没有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

尝试禁用你的gemfile中的美洲狮宝石#宝石'美洲狮','〜> 3.4',看看这是否会改变任何事情。 – mrvncaragay

+0

谢谢mrvncaragay!只有当我从生产中移除美洲狮时,它才会起作用,但我确实需要在生产模式 – ChaosPredictor

+0

中轻松修复美洲狮。在挖掘模式下取消注释。在开发模式中发表评论:) – mrvncaragay

回答

1

这不是一个真正的解决方案,但一个很好的工作,周围的人,使用有服务器的生产模式与彪马希望在本地机器开发工作WEBrick模式。这对mrvncaragay想法解决方案的基础

1. 分裂您Gemfile 3个文件:

Gemfile_base 
Gemfile_development 
Gemfile_production 

在Gemfile_base包括所有的gem s表示没有测试,开发&生产。没有理由包含source 'https://rubygems.org'或Gemfile_development或Gemfile_production文件。 在Gemfile_development只包括测试&发展gem小号 在Gemfile_production只包括生产gem小号

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 
+0

你为什么要这样做,而不是使用bundler的组功能? –

+1

@FrederickCheung,因为在生产模式下'group'完全不能使用'puma'([Check this](http://github.com/puma/puma/issues/983))。无论如何,这不是我可以在我的系统中实现的解决方案,而是试图以某种方式重新发明轮子。我将继续在开发中使用puma,直到更好的选项(或错误修复)到达。 –