首页 文章

Heroku部署错误H10(App崩溃)

提问于
浏览
113

我有一个RoR应用程序在我的本地计算机上工作,但当我将它发送到heroku时,它崩溃了 . 错误日志给出错误H10并说:

2012-11-21T15:26:47+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.4.2/lib/new_relic/control/instance_methods.rb:95:in `start_agent'
    2012-11-21T15:26:48+00:00 heroku[web.1]: State changed from starting to crashed
    2012-11-21T15:26:48+00:00 heroku[web.1]: Process exited with status 1
    2012-11-21T15:26:59+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=xxx.herokuapp.com fwd= dyno= queue= wait= connect= service= status=503 bytes=
    2012-11-21T15:27:00+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=xxx.herokuapp.com fwd= dyno= queue= wait= connect= service= status=503 bytes=
    2012-11-21T15:30:08+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=xxx.herokuapp.com fwd= dyno= queue= wait= connect= service= status=503 bytes=
    2012-11-21T15:30:08+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=xxx.herokuapp.com fwd= dyno= queue= wait= connect= service= status=503 bytes=
    2012-11-21T15:30:59+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=xxx.herokuapp.com fwd= dyno= queue= wait= connect= service= status=503 bytes=
    2012-11-21T15:31:19+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=xxx.herokuapp.com fwd= dyno= queue= wait= connect= service= status=503 bytes=
    2012-11-21T15:31:19+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=xxx.herokuapp.com fwd= dyno= queue= wait= connect= service= status=503 bytes=
    2012-11-21T15:32:08+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=xxx.herokuapp.com fwd= dyno= queue= wait= connect= service= status=503 bytes=
    2012-11-21T15:32:08+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=xxx.herokuapp.com fwd= dyno= queue= wait= connect= service= status=503 bytes=

编辑:

2012-11-22T10:00:58+00:00 app[web.1]: 
2012-11-22T10:00:59+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=xxx.herokuapp.com fwd= dyno=web.1 queue=0 wait=0ms connect=1ms service=26ms status=200 bytes=0

有没有人曾经有这个,并知道可能导致问题的原因是什么?我找不到解决方案 .

谢谢 .

26 回答

  • 10

    有同样的问题 . 对我来说这是在before_action过滤器中的错误(因为空数据库)检查你的before_action过滤器,也许他们抛出无限制的exeptions .

  • 2

    我推到Git解决了这个问题:

    git add .
    git commit -am "some text"
    git push
    

    然后推送到Heroku:

    git push heroku
    

    然后在Heroku上rake db:migrate:

    heroku run rake db:migrate
    
  • 1

    我从app.set更新了我的设置('ip_address',process.env.IP || '127.0.0.1' );

    app.set('ip_address',process.env.IP || '0.0.0.0' );

    我改为Openshift托管

  • 0

    由于主代码文件的名称错误,我与Heroku和Node有 H10 . 编辑 package.json

    {
    
      ...
    
      "main": "correct_file_name.js",
    
      ...
    
      "scripts": {
        "start": "node correct_file_name.js"
      }
    }
    

    或者重命名该文件 .

  • 1

    在我的情况下, Procfile 我使用的是打破一切 . Heroku在启动应用程序时查找 Procfile 并应用其设置 - 显然我使用的开发设置对prod服务器没有任何意义 . 我不得不将其重命名为 Procfile.dev ,一切正常 .

  • 1

    对复制和粘贴代码要非常谨慎 . 有时,当您将一个块添加到文件中时,它的格式不正确并将产生错误 .

    我之前遇到过这个问题并得到了这个错误:意外的tIDENTIFIER,期待keyword_end

  • 11

    我遇到了同样的错误,应用程序崩溃了heroku(在dev中运行正常)但是heroku上的错误日志没有透露任何线索 . 我在这个页面上阅读了其他答案,并在看到“重建应用程序”后大汗淋漓 . 我想也许我可以进入heroku控制台并环顾四周 . 我做了,甚至控制台崩溃了,但这次它告诉我为什么 . 这是一个模糊的变量,我忘了在早些时候的故障排除会话中删除 . 我并不是说你会遇到同样的问题,但是当我试图通过控制台时,我发现了更多信息 . 希望这可以帮助 .

    $ heroku run rails console
    
  • 2

    我遇到了同样的问题 . 日志也没有给我任何线索 . 所以我按比例缩小并缩小了dynos . 这解决了我的问题:

    heroku ps:scale web=0
    

    等了几秒钟......

    heroku ps:scale web=1
    
  • 5
    $heroku run rails console
    

    这是最好的选择,因为它会在你的终端中给你一个错误,它会比你的Heroku日志中的'app crashed'错误更加详细 .

  • 1
    $ heroku restart
    

    帮助我让我的dyno再次运行 . 我是Heroku的新手,但很高兴我现在知道了 .

  • 0

    当我在错误的端口上听时,这发生在我身上

    我将listen()更改为“process.env.PORT”,因此:

    http.listen((process.env.PORT || 5000), function(){
      console.log('listening on *:5000');
    });
    

    代替

    http.listen(5000, function(){
      console.log('listening on *:5000');
    });
    
  • 0

    今天晚上有同样的问题 . 这不是一个非常有用的错误,所以我尝试在控制台中运行

    heroku run rails c
    

    它失败了,给了我一个更有帮助的错误 . 我忽略了删除 生产环境 中的方法调用 . 一旦我解决了这个问题,应用程序运行良好 .

  • 36

    我设法不包括我的.gitignore文件 - >打破了heroku . #doh

    这是一个工作的.gitignore文件

    /.bundle
    /vendor/bundle/
    /vendor/ruby/
    
    
    db/*.sqlite3
    /db/*.sqlite3-journal
    /log/*
    /tmp/*
    
    
    **.war
    *.rbc
    *.sassc
    .redcar/
    .sass-cache
    /config/config.yml
    /config/database.yml
    /coverage.data
    /coverage/
    /db/*.javadb/
    /db/*.sqlite3
    /doc/api/
    /doc/app/
    /doc/features.html
    /doc/specs.html
    /public/cache
    /public/stylesheets/compiled
    /public/system/*
    /spec/tmp/*
    /cache
    /capybara*
    /capybara-*.html
    /gems
    /specifications
    rerun.txt
    pickle-email-*.html
    .zeus.sock
    
    **.orig
    
    .DS_Store
    
    /nbproject/
    
    .idea
    
    /*.tmproj
    
    **.swp
    
    .env
    .powenv
    

    要创建.gitignore文件,请在终端中导航到您的apps目录并使用以下命令

    touch .gitignore
    

    然后,您可以在文本编辑器中打开它并将上面的代码放入其中 .

  • 15

    我在Heroku中遇到了同样的H10应用程序崩溃错误 . 我点击了heroku界面中的'重启所有dynos',问题解决了 .

  • 0

    在我的情况下,我在我的应用程序中使用ENV变量,但它没有在heroku配置中设置 .

    heroku控制台给出了正确的错误:

    heroku console
    `validate_options': Missing required arguments: aws_access_key_id, aws_secret_access_key (ArgumentError)
    

    然后设置ENV配置

    heroku config:set AWS_ACCESS_KEY_ID='key'
    

    重启Heroku

    heroku restart
    

    有用!!

  • 0

    看看你是否得到

    bash: bin/rails: No such file or directory
    

    在运行时记录日志(heroku logs -t)如果是,请运行

    bundle exec rake rails:update
    

    不要覆盖你的文件,最后这个命令会创建

    create  bin
      create  bin/bundle
      create  bin/rails
      create  bin/rake
    

    将这些文件推送到heroku,你就完成了 .

  • 0

    我面临的问题的根源是由于没有数据库 . 要解决此问题,我首先导出了我的本地数据库:

    $ heroku addons:add heroku-postgresql:dev 
    $ heroku addons:add pgbackups
    $ PGPASSWORD=mypassword pg_dump -Fc --no-acl --no-owner -h localhost -U myuser mydb > mydb.dump
    

    然后将其导入Heroku:

    $ heroku pgbackups:restore DATABASE 'http://site.tld/mydb.dump'
    

    在这些示例中要替换的变量是: mypasswordmyusermydbhttp://site.tld/mydb.dump . 请注意,我必须将转储上载到临时服务器 .

    解决了我的所有问题,我写了一个关于如何将Enki部署到Heroku的快速指南,which can be found here .

  • 0

    我得到了与“app crashed”相同的上述错误,并且heroku app日志没有显示与错误消息相关的太多信息 . 然后我重新启动了heroku中的dynos,然后它显示错误,在我的设置中的一个index.js文件中说了额外的花括号 . 一旦删除并在heroku上重新部署应用程序,问题就解决了 .

    希望这对面临同样问题的人有所帮助 .

  • 0

    经过整个答案列表后,我偶然发现了这个网站:https://status.heroku.com/详细介绍了Heroku的当前状态/事件 . 在将头撞在墙上之前检查事故总是安全的 . 对我来说,上面提到的链接上发布的附加事件报告导致了错误 .

    SERVER INCIDENT UPDATE

  • 0

    我有同样的问题,我做了以下

    heroku run rails c
    

    它在控制器允许的参数中识别出语法错误和缺少逗号 . 如上所述,Heroku日志没有提供足够的信息来解决问题 .

    我之前没有在Heroku上看过应用程序崩溃的消息 .

  • 18

    我遇到了同样的事情今天的问题 . 我做了 heroku run rake db:migrate 虽然我之前迁移了模型,但应用程序没有崩溃 .

  • 0

    尝试在子目录中运行Rails时遇到此问题,而不是在 / 中 . 例如,我在 /client 中运行了Angular / Node / Gulp应用程序,在 /server 中运行了一个Rails应用程序,但它们都在同一个git仓库中,因此我可以跟踪前端和后端的变化 . 尝试将它们部署到Heroku时出现此错误 . 对于其他任何有此问题的人,这里有一个自定义buildpack,允许在子目录中运行Rails .

    https://github.com/aarongray/heroku-buildpack-ruby

  • 0

    我遇到了同样的问题(heroku上的错误,在本地机器上工作)我尝试了这里列出的所有解决方案,包括运行时没有错误消息的 heroku run rails console . 我试过几次 heroku run rake db:migrateheroku run rake db:migrate:reset . 这些都没有解决问题 . 在浏览一些在 生产环境 中但不在dev环境中使用的文件时,我发现puma.rb文件中有一些空格是罪魁祸首 . 希望这有助于有同样问题的人 . 改变它使它工作

    ActiveRecord::Base.establish_connection
      End
    

    ActiveRecord::Base.establish_connection
    end
    
  • 248

    我在部署到Heroku(应用程序崩溃)时遇到了同样的问题 . 日志没有说明问题可能是什么 . Heroku控制台在额外括号的代码中显示语法错误 . 令人惊讶的是,我在运行应用程序时没有在本地轨道上出现问题,因此错过了它 . 经过修正和git推送到Heroku后,该应用程序开始在Heroku上工作!

  • 1

    我按照their guide页面开始在heroku中使用Puma时遇到了同样的问题,当我评论下面显示的端口线时,这个问题就解决了

    # port        ENV['PORT']     || 3000
    

    因此,在config目录中禁用puma.rb中的上述行解决了这个问题

    workers Integer(ENV['WEB_CONCURRENCY'] || 2)
    threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 5)
    threads threads_count, threads_count
    
    preload_app!
    
    rackup      DefaultRackup
    # port        ENV['PORT']     || 3000
    environment ENV['RACK_ENV'] || 'production'
    
    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
    
  • 2

    如果您正在使用Node,则可以尝试直接在控制台中运行serve命令 . 在我的情况下,我正在运行一个角度应用程序,所以我试过:

    heroku run npm start
    

    这向我展示了应用程序启动期间的确切错误 .

相关问题