我正在尝试在Heroku上运行Node.js应用程序,但看到R10和H10错误。
以下是Heroku日志:
(注意:在我的Heroku日志中,我遇到了这个 gitAccess@0.0.0 start / app 它应该是app.js但我已经在package.json中正确声明了。)
1. C:\project\gitAccess>heroku logs
C:\project\gitAccess>heroku logs
2016-09-26T15:17:46.982704+00:00 heroku[api]: Release v2 created by sacdh2@gmail
.com
2016-09-26T15:17:46.982704+00:00 heroku[api]: Enable Logplex by sacdh2@gmail.com
2016-09-26T15:19:39.879219+00:00 heroku[api]: Scale to web=1 by sacdh2@gmail.com
2016-09-26T15:19:39.879734+00:00 heroku[api]: Deploy 14b360e by sacdh2@gmail.com
2016-09-26T15:19:39.879872+00:00 heroku[api]: Release v3 created by sacdh2@gmail
.com
2016-09-26T15:19:40.380795+00:00 heroku[slug-compiler]: Slug compilation started
2016-09-26T15:19:40.380800+00:00 heroku[slug-compiler]: Slug compilation finishe
d
2016-09-26T15:19:41.542552+00:00 heroku[web.1]: Starting process with command `n
pm start`
2016-09-26T15:19:43.849669+00:00 app[web.1]:
2016-09-26T15:19:43.849685+00:00 app[web.1]: > gitAccess@0.0.0 start /app
2016-09-26T15:19:43.849687+00:00 app[web.1]:
2016-09-26T15:19:43.849686+00:00 app[web.1]: > node ./app
2016-09-26T15:20:41.633728+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web
process failed to bind to $PORT within 60 seconds of launch
2016-09-26T15:20:41.633728+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-09-26T15:20:41.800843+00:00 heroku[web.1]: State changed from starting to c
rashed
2016-09-26T15:20:41.802015+00:00 heroku[web.1]: State changed from crashed to st
arting
2016-09-26T15:20:41.745945+00:00 heroku[web.1]: Process exited with status 137
2016-09-26T15:20:43.458207+00:00 heroku[web.1]: Starting process with command `n
pm start`
2016-09-26T15:20:46.191870+00:00 app[web.1]:
2016-09-26T15:20:46.191888+00:00 app[web.1]: > gitAccess@0.0.0 start /app
2016-09-26T15:20:46.191889+00:00 app[web.1]: > node ./app
2016-09-26T15:20:46.191890+00:00 app[web.1]:
2016-09-26T15:21:44.040560+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web
process failed to bind to $PORT within 60 seconds of launch
2016-09-26T15:21:44.040699+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-09-26T15:21:44.140816+00:00 heroku[web.1]: Process exited with status 137
2016-09-26T15:21:44.129449+00:00 heroku[web.1]: State changed from starting to c
rashed
2016-09-26T15:21:46.709334+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/" host=radiant-cliffs-71522.herokuapp.com request_id=fe3
cf7f7-b223-4f21-b7a4-d4f37af7dac6 fwd="115.99.170.213" dyno= connect= service= s
tatus=503 bytes=
2016-09-26T15:21:49.464884+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/favicon.ico" host=radiant-cliffs-71522.herokuapp.com req
uest_id=6cc6cee2-36f7-40e1-a156-17651ad00667 fwd="115.99.170.213" dyno= connect=
service= status=503 bytes=
2016-09-26T15:23:52.090333+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/" host=radiant-cliffs-71522.herokuapp.com request_id=6ba
f1018-77bb-45be-8780-6fd31e381c80 fwd="115.99.170.213" dyno= connect= service= s
tatus=503 bytes=
2016-09-26T15:23:53.780265+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/favicon.ico" host=radiant-cliffs-71522.herokuapp.com req
uest_id=f2db6452-348a-4446-8b2b-aecfd8a2f457 fwd="115.99.170.213" dyno= connect=
service= status=503 bytes=
2016-09-26T15:30:51.296851+00:00 heroku[api]: Deploy 60e8c27 by sacdh2@gmail.com
2016-09-26T15:30:51.296938+00:00 heroku[api]: Release v4 created by sacdh2@gmail
.com
2016-09-26T15:30:51.571152+00:00 heroku[slug-compiler]: Slug compilation started
2016-09-26T15:30:51.571161+00:00 heroku[slug-compiler]: Slug compilation finishe
d
2016-09-26T15:30:51.922270+00:00 heroku[web.1]: State changed from crashed to st
arting
2016-09-26T15:30:53.138220+00:00 heroku[web.1]: Starting process with command `:
node app.js`
2016-09-26T15:30:55.291163+00:00 heroku[web.1]: Process exited with status 0
2016-09-26T15:30:55.308919+00:00 heroku[web.1]: State changed from starting to c
rashed
2016-09-26T15:31:27.148553+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/" host=radiant-cliffs-71522.herokuapp.com request_id=a93
fb912-7cc4-4413-871a-33021bf66eef fwd="115.99.170.213" dyno= connect= service= s
tatus=503 bytes=
2016-09-26T15:31:28.304843+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/favicon.ico" host=radiant-cliffs-71522.herokuapp.com req
uest_id=df2015c6-e9e3-432e-8d11-55169d7e77b3 fwd="115.99.170.213" dyno= connect=
service= status=503 bytes=
2016-09-26T15:31:36.454736+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/" host=radiant-cliffs-71522.herokuapp.com request_id=597
268c2-6d18-425b-aebc-2cfe6051d308 fwd="115.99.170.213" dyno= connect= service= s
tatus=503 bytes=
2016-09-26T15:31:36.774936+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/favicon.ico" host=radiant-cliffs-71522.herokuapp.com req
uest_id=438dd5e0-bcb6-4b11-82b9-a464d8cef5c0 fwd="115.99.170.213" dyno= connect=
service= status=503 bytes=
2016-09-26T15:32:02.283353+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/" host=radiant-cliffs-71522.herokuapp.com request_id=514
eb7a4-904c-4364-ad93-003282019db5 fwd="115.99.170.213" dyno= connect= service= s
tatus=503 bytes=
2016-09-26T15:32:04.043738+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/favicon.ico" host=radiant-cliffs-71522.herokuapp.com req
uest_id=5ccfecca-0f7a-4b0c-a884-0f7709821c74 fwd="115.99.170.213" dyno= connect=
service= status=503 bytes=
2016-09-26T15:36:25.550391+00:00 heroku[api]: Deploy 4c1c8b7 by sacdh2@gmail.com
2016-09-26T15:36:25.550391+00:00 heroku[api]: Release v5 created by sacdh2@gmail
.com
2016-09-26T15:36:25.941408+00:00 heroku[slug-compiler]: Slug compilation started
2016-09-26T15:36:25.941417+00:00 heroku[slug-compiler]: Slug compilation finishe
d
2016-09-26T15:36:27.272615+00:00 heroku[web.1]: State changed from crashed to st
arting
2016-09-26T15:36:28.295815+00:00 heroku[web.1]: Starting process with command `:
node app.js`
2016-09-26T15:36:30.323543+00:00 heroku[web.1]: Process exited with status 0
2016-09-26T15:36:30.339915+00:00 heroku[web.1]: State changed from starting to c
rashed
2016-09-26T15:36:30.341235+00:00 heroku[web.1]: State changed from crashed to st
arting
2016-09-26T15:36:31.474676+00:00 heroku[web.1]: Starting process with command `:
node app.js`
2016-09-26T15:36:33.785629+00:00 heroku[web.1]: Process exited with status 0
2016-09-26T15:36:33.815017+00:00 heroku[web.1]: State changed from starting to c
rashed
2016-09-26T15:36:34.719231+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/" host=radiant-cliffs-71522.herokuapp.com request_id=6d6
f9e90-298c-4b08-aa57-6f10559e4c55 fwd="115.99.170.213" dyno= connect= service= s
tatus=503 bytes=
2016-09-26T15:36:36.389957+00:00 heroku[web.1]: State changed from crashed to st
arting
2016-09-26T15:36:36.438156+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/browserconfig.xml" host=radiant-cliffs-71522.herokuapp.c
om request_id=8eed6f7f-ee60-416e-baae-773808cdc054 fwd="115.99.170.213" dyno= co
nnect= service= status=503 bytes=
2016-09-26T15:37:11.368116+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/" host=radiant-cliffs-71522.herokuapp.com request_id=68c
938b2-9458-4fcb-b9ce-7ebe3a494c04 fwd="115.99.170.213" dyno= connect= service= s
tatus=503 bytes=
2016-09-26T15:38:56.055760+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/" host=radiant-cliffs-71522.herokuapp.com request_id=332
3e9fa-8b2c-4a25-9300-b84dcde617b4 fwd="115.99.170.213" dyno= connect= service= s
tatus=503 bytes=
2016-09-26T15:39:19.197478+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/" host=radiant-cliffs-71522.herokuapp.com request_id=d26
5c548-ba8d-4c75-8c4b-93f49f80da7e fwd="115.99.170.213" dyno= connect= service= s
tatus=503 bytes=
2016-09-26T15:39:32.608048+00:00 heroku[router]: at=error code=H10 desc="App
C:\project\gitAccess>
我的app.Js文件看起来像这样
var https = require("https");
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var cookieParser = require('cookie-parser');
var path = require('path');
var routes = require('./server');
// setting up middlewares
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.use(express.static(path.join(__dirname, 'public')));
app.get('/', function(req, res, next) {
res.sendFile(path.join(__dirname, 'views', 'index.html'));
});
app.listen(process.env.PORT || 3000, function(){
console.log("Express server listening on port %d in %s mode", this.address().port, app.settings.env);
});
module.exports = app;
这是我的package.json文件
{
"name": "gitAccess",
"version": "v4.2.4",
"private": true,
"scripts": {
"start": "node ./app.js"
},
"dependencies": {
"bluebird": "^3.4.6",
"body-parser": "^1.15.2",
"express": "^4.14.0",
"github": "^3.1.0",
"moment": "^2.15.1",
"parse-github-url": "^0.3.2"
},
"engines" :{
"node" : "0.12.7"
}
}
我也将我的Procfile设置为 web:node app.js
哪里可以出错?
编辑:我的server.Js文件
var https = require("https");
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var gh = require('parse-github-url'); // use to break the url user provides into various parts
var moment = require('moment'); // for Parse, validate, manipulate, and display dates in JavaScript.
var router = express.Router();
var Promise = require('bluebird');
var _ = require('underscore-node');
router.post('/click', function(req, res){
var url = gh(req.body.url);
var userName = url.owner;
var repo = url.name;
var currentDate = new Date();
var pastDay = moment(currentDate).subtract(24, 'hours').format("MM-DD-YYYY HH:mm:ss");
var pastWeek = moment(currentDate).subtract(7, 'days').format("MM-DD-YYYY HH:mm:ss");
var options = {
host: "api.github.com",
path: '/repos/' + userName + '/' + repo + '/issues',
method: 'GET',
headers: {'User-Agent': 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)'}
}
var request1 = https.request(options, function (response) {
var body = '';
response.on('data', function (chunk) {
body += chunk;
});
response.on('end', function () {
var json = JSON.parse(body);
var currentDate = new Date();
getPastDayIssues(json,pastDay, pastWeek).then(function(data){
res.send({"total" : data});
});
});
})
request1.on('error', function (e) {
console.error('and the error is ' + e);
});
request1.end();
});
function getPastDayIssues(issues, pastDate, pastWeek) {
return new Promise(function (resolve, reject) {
var i=0;var j=0;var k=0;
var total = {};
total.all = issues.length;
_.forEach(issues, function(data){
var createdDate = new Date(data.created_at);
var createdAt = moment(createdDate).format("MM-DD-YYYY HH:mm:ss");
//Comparing the dates using Moment and adding it to an object
if(moment(createdAt).isAfter(pastDate)){
i = i+1;
total.pastDay = i;
}
else if((moment(createdAt).isAfter(pastWeek)) &&( moment(createdAt).isBefore(pastDate))){
j = j+1;
total.pastWeek = j;
}
else if((moment(createdAt).isBefore(pastWeek)) ){
k = k+1;
total.pastAll = k;
}
});
resolve(total);
});
}
module.exports = router;
答案 0 :(得分:2)
看起来你的错误是因为你需要不在你的package.json文件中的节点模块(因此当Heroku站起来时不会导入你的应用程序的dyno)。
例如,underscore-node
。
作为一种习惯,我总是npm install <modulename> --save
确保它进入package.json。