Heroku migration to Cedar - "ERROR: No application configured, nothing to run"

Heroku migration to Cedar - "ERROR: No application configured, nothing to run"

我正在尝试将 Rails 应用程序上的旧 Heroku Ruby 从 Bamboo 迁移到 Cedar 堆栈。我正在使用 Ruby 1.8.7、Rails 2.3.11 和 Postgres 数据库。

我按照 https://devcenter.heroku.com/articles/cedar-migration 中的说明进行了所有操作,但是通过应用程序启动,我在 heroku 日志中收到消息:

"ERROR: No application configured, nothing to run"

我的个人资料:

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

config/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
  # Worker specific setup for Rails 4.1+
  # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
  ActiveRecord::Base.establish_connection
end

宝石文件:

source 'http://rubygems.org'
ruby '1.8.7'
gem 'rake', '~> 0.8.3'
gem 'rails', '2.3.11'
gem 'puma'
gem 'pg', '0.14.1'
gem 'rdoc'

Rakefile:

# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require(File.join(File.dirname(__FILE__), 'config', 'boot'))

require 'rake'
require 'rake/testtask'
require 'rdoc/task'
require 'tasks/rails'

本地捆绑包安装工作正常。我在服务器上调用这样的命令:

$ heroku buildpack:set https://github.com/heroku/heroku-buildpack-ruby#legacy-ruby-1.8.7

将提交推送到 Heroku 并执行成功的数据库迁移后,我仍然收到日志:

2015-03-11T19:09:53.619567+00:00 heroku[web.1]: State changed from crashed to starting
2015-03-11T19:09:53.614080+00:00 heroku[web.1]: Process exited with status 1
2015-03-11T19:09:57.902538+00:00 heroku[web.1]: Starting process with command `bundle exec puma -C config/puma.rb`
2015-03-11T19:10:00.320289+00:00 app[web.1]: [3] * Version 2.11.1 (ruby 1.8.7-p376), codename: Intrepid Squirrel
2015-03-11T19:10:00.320353+00:00 app[web.1]: [3] * Min threads: 5, max threads: 5
2015-03-11T19:10:00.320162+00:00 app[web.1]: [3] Puma starting in cluster mode...
2015-03-11T19:10:00.320497+00:00 app[web.1]: [3] * Preloading application
2015-03-11T19:10:00.320396+00:00 app[web.1]: [3] * Environment: production
2015-03-11T19:10:00.320452+00:00 app[web.1]: [3] * Process workers: 2
2015-03-11T19:10:00.320593+00:00 app[web.1]: [3] ERROR: No application configured, nothing to run
2015-03-11T19:10:01.138174+00:00 heroku[web.1]: Process exited with status 1
2015-03-11T19:10:01.145537+00:00 heroku[web.1]: State changed from starting to crashed

编辑 1:

Малъ,谢谢你的回答。我执行了您推荐的所有步骤,直到第 8 点。然后我将更改推送到 Heroku。日志现在是这样的:

2015-03-14T19:16:17.146877+00:00 heroku[web.1]: Starting process with command `bundle exec rackup -s puma -p ${PORT:-3000} -E ${RACK_ENV:-development}`
2015-03-14T19:16:18.986661+00:00 app[web.1]: NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
2015-03-14T19:16:18.986682+00:00 app[web.1]: Gem.source_index called from ./config/../vendor/rails/railties/lib/rails/gem_dependency.rb:21.
2015-03-14T19:16:18.987408+00:00 app[web.1]: NOTE: Gem::SourceIndex#refresh! is deprecated with no replacement. It will be removed on or after 2011-11-01.
2015-03-14T19:16:18.987505+00:00 app[web.1]: NOTE: Gem::SourceIndex#load_gems_in is deprecated with no replacement. It will be removed on or after 2011-11-01.
2015-03-14T19:16:18.987522+00:00 app[web.1]: Gem::SourceIndex#load_gems_in called from /app/vendor/ruby-1.8.7/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:322.
2015-03-14T19:16:18.988403+00:00 app[web.1]: NOTE: Gem::SourceIndex#add_spec is deprecated, use Specification.add_spec. It will be removed on or after 2011-11-01.
2015-03-14T19:16:18.989216+00:00 app[web.1]: NOTE: Gem::SourceIndex#add_spec is deprecated, use Specification.add_spec. It will be removed on or after 2011-11-01.
2015-03-14T19:16:18.989842+00:00 app[web.1]: NOTE: Gem::SourceIndex#add_spec is deprecated, use Specification.add_spec. It will be removed on or after 2011-11-01.
2015-03-14T19:16:18.988482+00:00 app[web.1]: Gem::SourceIndex#add_spec called from /app/vendor/ruby-1.8.7/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:127.
2015-03-14T19:16:18.989863+00:00 app[web.1]: Gem::SourceIndex#add_spec called from /app/vendor/ruby-1.8.7/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:127.
2015-03-14T19:16:18.987432+00:00 app[web.1]: Gem::SourceIndex#refresh! called from ./config/../vendor/rails/railties/lib/rails/vendor_gem_source_index.rb:34.
2015-03-14T19:16:18.989238+00:00 app[web.1]: Gem::SourceIndex#add_spec called from /app/vendor/ruby-1.8.7/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:127.
2015-03-14T19:16:18.990514+00:00 app[web.1]: NOTE: Gem::SourceIndex#add_spec is deprecated, use Specification.add_spec. It will be removed on or after 2011-11-01.
2015-03-14T19:16:18.994219+00:00 app[web.1]: Gem::SourceIndex#add_spec called from /app/vendor/ruby-1.8.7/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:127.
2015-03-14T19:16:18.994225+00:00 app[web.1]: NOTE: Gem::SourceIndex#add_spec is deprecated, use Specification.add_spec. It will be removed on or after 2011-11-01.
2015-03-14T19:16:18.994227+00:00 app[web.1]: Gem::SourceIndex#add_spec called from /app/vendor/ruby-1.8.7/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:127.
2015-03-14T19:16:18.994229+00:00 app[web.1]: ./config/environment.rb:43: warning: already initialized constant MONTHNAMES
2015-03-14T19:16:19.112792+00:00 app[web.1]: ./config/../vendor/rails/railties/lib/initializer.rb:271:in `require_frameworks': can't activate rack (~> 1.1.0), already activated rack-1.4.5. Make sure all dependencies are added to Gemfile. (RuntimeError)
2015-03-14T19:16:19.112801+00:00 app[web.1]:    from ./config/../vendor/rails/railties/lib/initializer.rb:113:in `run'
2015-03-14T19:16:19.112798+00:00 app[web.1]:    from ./config/../vendor/rails/railties/lib/initializer.rb:134:in `process'
2015-03-14T19:16:19.112808+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.8/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
2015-03-14T19:16:19.112799+00:00 app[web.1]:    from ./config/../vendor/rails/railties/lib/initializer.rb:113:in `send'
2015-03-14T19:16:19.112806+00:00 app[web.1]:    from /app/config.ru:2:in `require'
2015-03-14T19:16:19.112802+00:00 app[web.1]:    from ./config/environment.rb:9
2015-03-14T19:16:19.112811+00:00 app[web.1]:    from /app/config.ru:0:in `new'
2015-03-14T19:16:19.112810+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.8/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
2015-03-14T19:16:19.112812+00:00 app[web.1]:    from /app/config.ru:0
2015-03-14T19:16:19.112807+00:00 app[web.1]:    from /app/config.ru:2
2015-03-14T19:16:19.870706+00:00 heroku[web.1]: Process exited with status 1
2015-03-14T19:16:19.882290+00:00 heroku[web.1]: State changed from starting to crashed

然后我尝试将 Gemfile 中的机架版本更新为 1.1.0,调用

$ bundle update rack

并再次上传资源。日志:

2015-03-14T19:08:30.722782+00:00 heroku[web.1]: State changed from crashed to starting
2015-03-14T19:08:35.270101+00:00 heroku[web.1]: Starting process with command `bundle exec rackup -s puma -p ${PORT:-3000} -E ${RACK_ENV:-development}`
2015-03-14T19:08:39.383233+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.8/gems/rack-1.1.6/lib/rack/handler.rb:21:in `get'
2015-03-14T19:08:39.383209+00:00 app[web.1]: /app/vendor/bundle/ruby/1.8/gems/rack-1.1.6/lib/rack/handler.rb:21:in `const_get': wrong constant name puma (NameError)
2015-03-14T19:08:39.383245+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.8/bin/rackup:23
2015-03-14T19:08:39.383236+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.8/gems/rack-1.1.6/lib/rack/server.rb:159:in `server'
2015-03-14T19:08:39.383239+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.8/gems/rack-1.1.6/lib/rack/server.rb:83:in `start'
2015-03-14T19:08:39.383242+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.8/gems/rack-1.1.6/bin/rackup:4
2015-03-14T19:08:39.383238+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.8/gems/rack-1.1.6/lib/rack/server.rb:155:in `start'
2015-03-14T19:08:39.383243+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.8/bin/rackup:23:in `load'
2015-03-14T19:08:40.314387+00:00 heroku[web.1]: State changed from starting to crashed
2015-03-14T19:08:40.299712+00:00 heroku[web.1]: Process exited with status 1

现在我完全不知道该如何处理。


编辑 2:

我注意到 sed 命令失败并且没有改变 vendor/rails/actionpack/lib/action_controller.rb 所以我添加了缺少的行:

gem 'rack', '~> 1.4.0'

当前日志:

2015-03-14T19:53:59.803670+00:00 heroku[web.1]: State changed from crashed to starting
2015-03-14T19:54:03.524424+00:00 heroku[web.1]: Starting process with command `bundle exec rackup -s puma -p ${PORT:-3000} -E ${RACK_ENV:-development}`
2015-03-14T19:54:05.617313+00:00 app[web.1]: Gem.source_index called from ./config/../vendor/rails/railties/lib/rails/gem_dependency.rb:21.
2015-03-14T19:54:05.618457+00:00 app[web.1]: NOTE: Gem::SourceIndex#refresh! is deprecated with no replacement. It will be removed on or after 2011-11-01.
2015-03-14T19:54:05.621176+00:00 app[web.1]: NOTE: Gem::SourceIndex#add_spec is deprecated, use Specification.add_spec. It will be removed on or after 2011-11-01.
2015-03-14T19:54:05.617253+00:00 app[web.1]: NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
2015-03-14T19:54:05.623472+00:00 app[web.1]: Gem::SourceIndex#add_spec called from /app/vendor/ruby-1.8.7/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:127.
2015-03-14T19:54:05.618569+00:00 app[web.1]: NOTE: Gem::SourceIndex#load_gems_in is deprecated with no replacement. It will be removed on or after 2011-11-01.
2015-03-14T19:54:05.620427+00:00 app[web.1]: NOTE: Gem::SourceIndex#add_spec is deprecated, use Specification.add_spec. It will be removed on or after 2011-11-01.
2015-03-14T19:54:05.620459+00:00 app[web.1]: Gem::SourceIndex#add_spec called from /app/vendor/ruby-1.8.7/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:127.
2015-03-14T19:54:05.622667+00:00 app[web.1]: Gem::SourceIndex#add_spec called from /app/vendor/ruby-1.8.7/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:127.
2015-03-14T19:54:05.618490+00:00 app[web.1]: Gem::SourceIndex#refresh! called from ./config/../vendor/rails/railties/lib/rails/vendor_gem_source_index.rb:34.
2015-03-14T19:54:05.621896+00:00 app[web.1]: NOTE: Gem::SourceIndex#add_spec is deprecated, use Specification.add_spec. It will be removed on or after 2011-11-01.
2015-03-14T19:54:05.624954+00:00 app[web.1]: ./config/environment.rb:43: warning: already initialized constant MONTHNAMES
2015-03-14T19:54:05.618605+00:00 app[web.1]: Gem::SourceIndex#load_gems_in called from /app/vendor/ruby-1.8.7/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:322.
2015-03-14T19:54:05.751623+00:00 app[web.1]: ./config/../vendor/rails/railties/lib/initializer.rb:271:in `require_frameworks': can't activate rack (~> 1.1.0), already activated rack-1.4.5. Make sure all dependencies are added to Gemfile. (RuntimeError)
2015-03-14T19:54:05.751649+00:00 app[web.1]:    from ./config/../vendor/rails/railties/lib/initializer.rb:134:in `process'
2015-03-14T19:54:05.621928+00:00 app[web.1]: Gem::SourceIndex#add_spec called from /app/vendor/ruby-1.8.7/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:127.
2015-03-14T19:54:05.622636+00:00 app[web.1]: NOTE: Gem::SourceIndex#add_spec is deprecated, use Specification.add_spec. It will be removed on or after 2011-11-01.
2015-03-14T19:54:05.751727+00:00 app[web.1]:    from ./config/environment.rb:9
2015-03-14T19:54:05.751802+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.8/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
2015-03-14T19:54:05.751707+00:00 app[web.1]:    from ./config/../vendor/rails/railties/lib/initializer.rb:113:in `run'
2015-03-14T19:54:05.751687+00:00 app[web.1]:    from ./config/../vendor/rails/railties/lib/initializer.rb:113:in `send'
2015-03-14T19:54:05.751841+00:00 app[web.1]:    from /app/config.ru:0:in `new'
2015-03-14T19:54:05.751765+00:00 app[web.1]:    from /app/config.ru:2
2015-03-14T19:54:05.751746+00:00 app[web.1]:    from /app/config.ru:2:in `require'
2015-03-14T19:54:05.751822+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.8/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
2015-03-14T19:54:05.751859+00:00 app[web.1]:    from /app/config.ru:0
2015-03-14T19:54:05.621284+00:00 app[web.1]: Gem::SourceIndex#add_spec called from /app/vendor/ruby-1.8.7/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:127.
2015-03-14T19:54:05.623441+00:00 app[web.1]: NOTE: Gem::SourceIndex#add_spec is deprecated, use Specification.add_spec. It will be removed on or after 2011-11-01.
2015-03-14T19:54:06.627025+00:00 heroku[web.1]: State changed from starting to crashed
2015-03-14T19:54:06.613881+00:00 heroku[web.1]: Process exited with status 1

编辑 3:

我忘记删除vendor/rails/actionpack/lib/action_controller.rb中带有rack 1.1.0版本的行。现在应用程序已经启动并且工作起来很有魅力。 Малъ,你是我的救世主!非常感谢。

我已经在 heroku cedar-10 堆栈上 运行 我的 Rails 2.3 应用程序做了一些步骤。不幸的是,它也将很快被删除,这样 heroku 支持就得到了回答。所以:

  1. 升级或降级rubygems1.4.2,需要运行rake冻结:

    $ gem update --system 1.4.2
    
  2. rake 添加到 Gemfile。和捆绑设置。

  3. 根据 manual,你必须首先将 Rails gem 冻结到 /vendor 文件夹中:

    $ rake rails:freeze:gems
    
  4. 修改文件:vendor/rails/actionpack/lib/action_controller.rb支持rack 1.4.0版本:

    $ sed "s/gem 'rack', '~> 1.1.0'/gem 'rack', '~> 1.4.0'/" -i vendor/rails/actionpack/lib/action_controller.rb
    
  5. rack 1.4.0puma 2.3.2gem添加到Gemfile,并删除 rails gem ,然后再次捆绑设置:

    gem 'rack', '~> 1.4.0'
    gem 'puma', '~> 2.3.2'
    

    注意: config/puma.rb 也不再需要了。

  6. 通过 rackup:

    Procfile 更改为 运行 puma
    $ cat Procfile
    web: bundle exec rackup -s puma -p ${PORT:-3000} -E ${RACK_ENV:-development}
    
  7. config.ru 添加到 运行 Rails 来自 rackup 的应用:

    $ cat config.ru
    # RAILS_ROOT/config.ru
    require "config/environment"
    
    use Rails::Rack::LogTailer
    use Rails::Rack::Static
    run ActionController::Dispatcher.new
    
  8. 将更改和新增的文件添加到git,并将更改推送到heroku。

  9. 由于heroku在生产中默认使用PostgreSQL,创建MySQL db实例,当然如果你打算使用它,根据manual

    $ heroku addons:add cleardb:ignite
    -----> Adding cleardb to sharp-mountain-4005... done, v18 (free)
    
    $ heroku config | grep CLEARDB_DATABASE_URL
    CLEARDB_DATABASE_URL => mysql://adffdadf2341:adf4234@us-cdbr-east.cleardb.com/heroku_db?reconnect=true
    
    $ heroku config:set DATABASE_URL='mysql://adffdadf2341:adf4234@us-cdbr-east.cleardb.com/heroku_db?reconnect=true'
    

此外,我必须删除服务器变量

STACK:                      bamboo-ree-1.8.7

并添加

RAILS_ENV:                  production

现在,原始应用程序(不是它的测试副本)可以工作了。

此致,

迈克尔

无论如何首先尝试在行尾添加 config.ru (Rails 3.X.X)

我的程序文件

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