Heroku迁移到Cedar - "错误:没有配置应用程序,没有任何运行"

时间:2015-03-11 19:57:20

标签: ruby-on-rails heroku migration puma cedar

我正在尝试将旧的Heroku Ruby on Rails应用程序从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"

我的Procfile:

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
  # 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

的Gemfile:

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'

Rake文件:

# 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中删除机架1.1.0版本的行。现在应用程序正在运行,就像一个魅力。 Малъ,你是我的救助者!非常感谢。

3 个答案:

答案 0 :(得分:3)

我已经完成了在heroku Rails 2.3堆栈上运行cedar-10应用的一些步骤。不幸的是,它也将很快被删除,以这种方式heroku支持回答。所以:

  1. rubygems升级或降级为1.4.2,需要运行rake冻结:

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

  3. 根据manual,您必须先将Rails个宝石冻结到 / 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. 将<{1}}和rack 1.4.0宝石添加到 Gemfile ,然后从中删除 puma 2.3.2 gem,然后捆绑再次安装:

    rails

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

  6. 更改 Procfile 以通过gem 'rack', '~> 1.4.0' gem 'puma', '~> 2.3.2' 运行puma

    rackup
  7. 添加 config.ru 以从$ cat Procfile web: bundle exec rackup -s puma -p ${PORT:-3000} -E ${RACK_ENV:-development} 运行Rails个应用:

    rackup
  8. 将更改后的和新添加的文件添加到git中,并将更改推送到heroku。

  9. 由于默认情况下heroku在生产中使用$ cat config.ru # RAILS_ROOT/config.ru require "config/environment" use Rails::Rack::LogTailer use Rails::Rack::Static run ActionController::Dispatcher.new ,因此创建PostgreSQL db实例,当然如果您打算使用它,则符合manual

    MySQL

答案 1 :(得分:0)

另外我不得不删除服务器变量

STACK:                      bamboo-ree-1.8.7

并添加

RAILS_ENV:                  production

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

此致

米哈尔

答案 2 :(得分:0)

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

我的Procfile

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