2016-03-07 64 views
0

我有一個部署在heroku上的美洲獅導軌應用程序。似乎一切都很好,除非我在dev env啓動我的應用程序的端口是5000而不是3000.rails localhost + heroku puma config

爲什麼會發生這種情況?根據我的配置文件,它應該回退到3000,就像線程和併發數字(那些工作正常)。

Procfile.dev

web: bundle exec puma -C config/puma.rb 

配置/ puma.rb

workers Integer(ENV['WEB_CONCURRENCY'] || 2) 
threads_count = Integer(ENV['MAX_THREADS'] || 5) 
threads threads_count, threads_count 

preload_app! 

rackup  DefaultRackup 
port  ENV['PORT']  || 3000 
environment ENV['RACK_ENV'] || 'development' 

on_worker_boot do 
    ActiveRecord::Base.establish_connection 
end 

爲什麼,工頭把$端口連接到過程與foreman start -f Procfile.dev

12:36:51 web.1  | [12816] Puma starting in cluster mode... 
12:36:51 web.1  | [12816] * Version 2.13.4 (ruby 2.2.3-p173), codename: A Midsummer Code's Dream 
12:36:51 web.1  | [12816] * Min threads: 5, max threads: 5 
12:36:51 web.1  | [12816] * Environment: development 
12:36:51 web.1  | [12816] * Process workers: 2 
12:36:51 web.1  | [12816] * Preloading application 
12:37:08 web.1  | [12816] * Listening on tcp://0.0.0.0:5000 
12:37:08 web.1  | [12816] ! WARNING: Detected 1 Thread(s) started in app boot: 
12:37:08 web.1  | [12816] ! #<Rack::MiniProfiler::FileStore::CacheCleanupThread:[email protected]/Users/Silo/.rvm/gems/ruby-2.2.3/gems/rack-mini-profiler-0.9.8/lib/mini_profiler/storage/file_store.rb:53 sleep> - /Users/Silo/.rvm/gems/ruby-2.2.3/gems/rack-mini-profiler-0.9.8/lib/mini_profiler/storage/file_store.rb:71:in `sleep' 
12:37:08 web.1  | [12816] Use Ctrl-C to stop 
12:37:08 web.1  | [12816] - Worker 0 (pid: 12822) booted, phase: 0 
12:37:08 web.1  | [12816] - Worker 1 (pid: 12823) booted, phase: 0 

回答

2

對於啓動服務器後,默認設置爲5000。因此,你的config/puma.rb中會忽略端口3000。請參閱此線程的末尾https://github.com/ddollar/foreman/issues/381

現在,有幾種方法可以解決此問題。例如,你可以按如下方式啓動工頭:foreman s -p 3000.這是我的首選解決方案,因爲它不涉及爲開發創建特定的proc文件,也不添加到.env文件(PORT = 3000),也不創建。工頭文件(端口:3000)。

如果您確實想使用您的開發proc文件,請將其更改如下:web: PORT=3000 bundle exec puma -C config/puma.rb