首页 文章

在上传到Heroku时,App崩溃了H10错误代码

提问于
浏览
0

我有一个节点应用程序,它在本地运行没有任何问题,但当我尝试使用heroku部署它时,我不能这样做 . 我得到的错误是:

2017-05-26T13:37:31.249587+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=engageitvisz.herokuapp.com request_id=e9641b76-0667-44ce-b85a-fb431c1cca2a fwd="31.10.149.171" dyno= connect= service= status=503 bytes= protocol=https

我在我的应用程序中使用mongoLab,但我在heroku中将其添加为插件 . 这是server.js:

var express = require('express');
var app = express();

var databaseUrl = "mongodb://user:pass@ds137090.mlab.com:37090/questions"; 
var collections = ["questions"];
var mongojs = require('mongojs');
var db = mongojs(databaseUrl, collections);

app.set('port', (process.env.PORT || 5002));

var bodyParser = require('body-parser');
app.use(express.static(__dirname + "/public"));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
app.get('/', function(request, response){
   response.send("Hello from server.js");
});

app.get('/questions', function(request, response){
   console.log("I received a GET request for questions");

db.questions.find(function(err, docs){
  if(err){
         response.send(err);
  }
  response.json(docs);
   })
});
app.post('/questions', function(request, response){
   console.log("I received a POST request for questions");

});

app.listen(app.get('port'), function(){
   console.log('Server running on port', app.get('port'));
});

Procfile:

web: node server.js

的package.json:

{
  "name": "engageit",
  "version": "1.0.0",
  "description": "EngageIt visualization",
  "main": "server.js",
  "dependencies": {
    "express": "4.13.1"
  },
  "repository": {
     "type": "git",
     "url": "https://github.com/VitezKoja92/EngageItVisz.git"
  },
  "scripts": {
    "test": "test",
    "start": "node server.js",
    "heroku-prebuild": "echo This runs before Heroku installs your dependencies.",
    "heroku-postbuild": "echo This runs afterwards."
  },
  "author": "Danilo Krasic",
  "license": "ISC",
  "keywords": [
    "node",
    "heroku",
    "express"
  ],
  "engines": {
    "node": "7.7.2"
  }
}

如果您有任何建议,请告诉我,因为我试图解决这个问题几个小时 .

3 回答

  • 0
    • 首先去herkou部署

    • 然后转到git hub和fork parse-server-example

    • 然后再次转到您的heroku仪表板并将您的应用程序链接到您的git提交

  • 0

    这看起来像是一个直接来自MongoLab的URI连接字符串 . 根据Heroku帮助页面,在项目的根目录中输入以下命令,尝试确保从MongoLab Heroku插件获取正确的连接URI:

    heroku config:get MONGODB_URI

  • 0

    我遇到了同样的问题:Heroku nodejs app deployment, app crash
    但是没有在stackoverflow上找到任何解决方案,从我无法找到导致崩溃的日志 .
    最后我从heroku删除了应用程序以及从本地系统中删除了Procfile,用随机名称( heroku create )在heroku上创建了一个应用程序,并使用没有Procfile的git将文件夹推送到heroku并重新启动了heroku,它对我有效 .

相关问题