我正在尝试将一个小型Rails应用程序部署到Bluemix。它在当地工作正常。我得到的错误是:
Instance (index 0) failed to start accepting connections
2015-12-13T20:57:11.571-0800[API/2]OUTApp instance exited with guid
68527a7d-ee7c-40a9-a500-0b44c01d267c payload:
{"cc_partition"=>"default",
"droplet"=>"68527a7d-ee7c-40a9-a500-0b44c01d267c",
"version"=>"3b480d7d-3483-435b-bbfc-b4682a9994e2",
"instance"=>"faed828f09364ac79a32503deaace288", "index"=>0,
"reason"=>"CRASHED", "exit_status"=>-1,
"exit_description"=>"failed to accept connections within health check timeout",
"crash_timestamp"=>1450069031}
到目前为止我发现的所有答案都说这是一个端口问题,而且当我使用
进行部署时也是如此cf push <myapp> --no-route
它很好,即没有错误消息。
我使用puma作为服务器和我的Procfile(带有拼写,它是根)已经
web: bundle exec puma -p $PORT
即便如此,Bluemix也开始使用puma,但总是使用端口3000.即使我放了类似的东西
web: bundle exec puma -p 1234
它从端口3000开始。 所以它似乎忽略了Procfile。我做错了什么?
根据Jeff的问题,我的buildpack是ruby 1.6.7,这是我的Gemfile:
source 'https://rubygems.org'
ruby "2.2.2"
gem 'rails', '4.2.1'
gem 'pg'
gem 'activerecord-postgresql-adapter'
gem 'cf-autoconfig', '~> 0.2.1'
gem 'rails_12factor'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
gem 'devise'
gem 'puma'
这是日志
2015-12-14T18:52:52.265-0800[STG/116]OUT-----> Uploading droplet (32M)
2015-12-14T18:53:00.626-0800[DEA/116]OUTStarting app instance (index 0) with guid 68527a7d-ee7c-40a9-a500-0b44c01d267c
2015-12-14T18:53:08.174-0800[App/0]OUT=> Booting Puma
2015-12-14T18:53:08.174-0800[App/0]OUT=> Rails 4.2.1 application starting in production on http://0.0.0.0:3000
2015-12-14T18:53:08.174-0800[App/0]OUT=> Run `rails server -h` for more startup options
2015-12-14T18:53:08.174-0800[App/0]OUT=> Ctrl-C to shutdown server
2015-12-14T18:53:09.038-0800[App/0]OUTPuma 2.15.3 starting...
2015-12-14T18:53:09.038-0800[App/0]OUT* Min threads: 0, max threads: 16
2015-12-14T18:53:09.038-0800[App/0]OUT* Environment: production
2015-12-14T18:53:09.038-0800[App/0]OUT* Listening on tcp://0.0.0.0:3000
2015-12-14T18:54:06.485-0800[DEA/116]ERRInstance (index 0) failed to start accepting connections
2015-12-14T18:54:06.488-0800[App/0]ERR
2015-12-14T18:54:06.487-0800[API/3]OUTApp instance exited with guid 68527a7d-ee7c-40a9-a500-0b44c01d267c payload:
{"cc_partition"=>"default", "droplet"=>"68527a7d-ee7c-40a9-a500-0b44c01d267c",
"version"=>"972ea1d8-aaf2-4fa8-a937-fad4024907f7",
"instance"=>"2c0a0d9d83a0442594596b42570ff3b8", "index"=>0,
"reason"=>"CRASHED", "exit_status"=>-1,
"exit_description"=>"failed to accept connections within health check timeout", "crash_timestamp"=>1450148046}
感谢您的帮助!
答案 0 :(得分:3)
首先看一下你在端口3000
上的开始。 Bluemix / Cloud Foundry为您分配一个可运行的端口。您需要manifest.yml
中的以下内容。您需要更换应用程序的信息。 $PORT
告诉Ruby绑定到Bluemix的指定端口。
---
applications:
#swap out myapp-jbs for your own app name
- name: myapp-jbs
memory: 1GB
instances: 1
path: .
command: bundle exec rake db:setup && bundle exec rails s -p $PORT
services:
#swap out the below for your own
#cf cs elephantsql turtle yourownname
- postgres-myapp
另外使用以下命令推送您的应用程序。
cf push -b https://github.com/cloudfoundry/ruby-buildpack.git