2016-08-13 141 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,直到更好的選項(或錯誤修復)到達。 –