I am building a NodeJS application using express here is my code:
var express = require('express');
var app = express();
var session = require('express-session');
var uuidv1 = require('uuid/v1');
require('dotenv').config();
var APIAI_TOKEN = process.env.APIAI_TOKEN;
var APIAI_SESSION_ID = uuidv1();
app.use(express.static(__dirname + '/views')); // html
app.use(express.static(__dirname + '/public')); // js, css, images
var server = require('http').createServer(app);
var port = process.env.port || 3000;
server.listen(port, function() {
console.log('Server listening at port: ', port);
// console.log(APIAI_SESSION_ID);
// console.log(APIAI_TOKEN);
});
app.use(session({
genid: function(req) {
return APIAI_SESSION_ID;
},
secret: 'secret',
saveUninitialized: true,
resave: true
}));
var io = require('socket.io')(server);
var apiai = require('apiai')(APIAI_TOKEN);
var rp = require('request-promise');
//#region Web UI
app.get('/', function(req, res) {
res.sendFile('index.html');
});
I start my app with node app and everything works perfectly on my localhost but when I deploy the app to Google App engine i get a 502 bad gateway error and when i check the log it happens at the app.get() method.
I even deployed it to Heroku server as well, the app is crashing at the same point. What could be wrong with my code?
Here is the log form Heroku server:
2017-11-01T16:35:57.528020+00:00 heroku[router]: at=error code=H10
desc="App crashed" method=GET path="/" host=ippcbot.herokuapp.com request_id=d956df30-8352-4a54-80e6-2aa1fc96276b fwd="197.210.37.211" dyno= connect= service= status=503 bytes= protocol=https
2017-11-01T16:35:58.138751+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ippcbot.herokuapp.com request_id=96b2bf0d-df05-4d7e-9018-0b09e1dfa748 fwd="197.210.37.211" dyno= connect= service= status=503 bytes= protocol=https
Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect...
2017-11-01T16:19:36.517868+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2017-11-01T16:19:36.513572+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2017-11-01T16:19:36.517927+00:00 app[web.1]: npm ERR! /app/npm-debug.log
2017-11-01T16:19:36.584087+00:00 heroku[web.1]: Process exited with status 1
2017-11-01T16:19:36.607609+00:00 heroku[web.1]: State changed from starting to crashed
2017-11-01T16:20:47.248202+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=ippcbot.herokuapp.com request_id=41e9f39b-e908-4cee-a430-0d7f44a17590 fwd="197.210.37.211" dyno= connect= service= status=503 bytes= protocol=https
2017-11-01T16:20:47.891459+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ippcbot.herokuapp.com request_id=9f244daf-7a3e-405e-b445-2fadd8b2735b fwd="197.210.37.211" dyno= connect= service= status=503 bytes= protocol=https
2017-11-01T16:35:13.187594+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=ippcbot.herokuapp.com request_id=455ccd5e-e389-49be-b892-e5e222c9864f fwd="197.210.37.211" dyno= connect= service= status=503 bytes= protocol=https
2017-11-01T16:35:13.805998+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ippcbot.herokuapp.com request_id=112a5f08-632e-463d-b8e8-ed6de13b3596 fwd="197.210.37.211" dyno= connect= service= status=503 bytes= protocol=https
2017-11-01T16:35:57.528020+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=ippcbot.herokuapp.com request_id=d956df30-8352-4a54-80e6-2aa1fc96276b fwd="197.210.37.211" dyno= connect= service= status=503 bytes= protocol=https
2017-11-01T16:35:58.138751+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ippcbot.herokuapp.com request_id=96b2bf0d-df05-4d7e-9018-0b09e1dfa748 fwd="197.210.37.211" dyno= connect= service= status=503 bytes= protocol=https
Not sure about Heroku, but for App Engine does changing the port to 8080 work?
For example:
const server = app.listen(8080, () => {
const host = server.address().address;
const port = server.address().port;
console.log(`Example app listening at http://${host}:${port}`);
});
From Run Express.js on Google App Engine Flexible Environment
Related
My first time deploying the website I got a long error as shown below.
2020-09-25T07:31:36.727714+00:00 heroku[web.1]: State changed from starting to crashed
2020-09-25T07:31:36.730015+00:00 heroku[web.1]: State changed from crashed to starting
2020-09-25T07:31:40.230036+00:00 heroku[web.1]: Starting process with command `node server.js`
2020-09-25T07:31:43.021415+00:00 heroku[web.1]: Process exited with status 1
2020-09-25T07:31:43.061920+00:00 heroku[web.1]: State changed from starting to crashed
2020-09-25T07:31:44.106774+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=secure-coast-24568.herokuapp.com request_id=3ba32d6b-e60d-4566-8a67-bf06d6957146 fwd="116.88.43.115" dyno= connect= service= status=503 bytes= protocol=https
2020-09-25T07:31:44.535220+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=secure-coast-24568.herokuapp.com request_id=2e8669b0-19cb-43aa-90c8-1e1770aa3e6a fwd="116.88.43.115" dyno= connect= service= status=503 bytes= protocol=https
2020-09-25T07:36:38.651280+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=secure-coast-24568.herokuapp.com request_id=0d39c46b-d0d8-4bfb-9516-1c8fae89dce6 fwd="116.88.43.115" dyno= connect= service= status=503 bytes= protocol=https
2020-09-25T07:36:39.102621+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=secure-coast-24568.herokuapp.com request_id=9b23f6b1-e2ec-4f12-8b25-cb000a229675 fwd="116.88.43.115" dyno= connect= service= status=503 bytes= protocol=https
2020-09-25T07:48:16.835509+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=secure-coast-24568.herokuapp.com request_id=956d30e4-a981-48fd-9ec9-2598975d3e1d fwd="116.88.43.115" dyno= connect= service= status=503 bytes= protocol=https
2020-09-25T07:48:17.345353+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=secure-coast-24568.herokuapp.com request_id=35947874-9055-4b74-ab76-31c4329e0c72 fwd="116.88.43.115" dyno= connect= service= status=503 bytes= protocol=https
I am not sure what is the cause of the problem but there were many others too getting the same errors which was rectified. Going through what they did to fix the problem I followed the steps but still got the same error. Currently the website is working 100% when used locally and I did multiple tests before I deployed it.
This is my server.js
const dotenv = require("dotenv");
const mongoose = require("mongoose");
const app = require("./app");
app.set("view engine", "ejs");
process.on("uncaughtException", () => {
process.exit(1);
});
dotenv.config({
path: "./config.env",
});
const DB = process.env.DATABASE.replace(
"<PASSWORD>",
process.env.DATABASE_PASSWORD
);
mongoose
.connect(DB, {
useNewUrlParser: true,
useCreateIndex: true,
useFindAndModify: false,
useUnifiedTopology: true,
})
.then(() => {
console.log("Success");
});
// Server
const port = process.env.PORT || "3000";
const server = app.listen(port, () => {
console.log("Server started");
});
// Handle all the errors in the async code that wasnt handle
process.on("unhandledRejection", () => {
server.close(() => {
process.exit(1);
});
});
My environment variables, e.g. DATABASE and DATABASE_PASSWORD, are set in a file called config.env, which is ignored via my .gitignore since it contains sensitive information.
Your config.env file should indeed be ignored. Sensitive information like your database credentials shouldn't be committed.
However, your application needs those values. On Heroku, the solution is to set config vars that get exposed to your application as environment variables. You can do this with the Heroku CLI, e.g.
heroku config:set DATABASE_PASSWORD=12345
or via the web dashboard.
Note that in most cases you shouldn't be setting database credentials manually on Heroku. Use a database addon and whatever config vars it sets, e.g. the Heroku Postgres service sets a variable called DATABASE_URL automatically.
I have a vuejs app which set up with vue cli, and i'm trying deploy my app to heroku.
Here's my server :
const express = require('express');
const port = process.env.PORT || 8080;
const app = express();
app.use(express.static(__dirname + "/dist/"));
app.get(/.*/ , function(req,res) {
res.sendfile(__dirname + "/dist/index.html");
});
app.listen(port);
console.log("Server started...");
I remove dist from gitignore,
I aded a start point like "start": "node server.js" in package.json
Here's what i see on console :
Failed to load resource: the server responded with a status of 503 (Service Unavailable) /favicon.ico:1
Here's heroku logs :
2019-12-13T08:55:49.464914+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=followgoals.herokuapp.com request_id=09df33ae-96ab-415a-929b-530fb943318d fwd="37.130.123.179" dyno= connect= service= status=503 bytes= protocol=https
2019-12-13T08:55:49.828341+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=followgoals.herokuapp.com request_id=21de7307-502e-4104-a648-8e6b0832a3fe fwd="37.130.123.179" dyno= connect= service= status=503 bytes= protocol=https
So what can i do the fix problem ?
I had the same problem, worked on local, 503 error on heroku, and I fixed it by going to my db cloud service(mongodb atlas), and changed the white list setting on my cluster from "home" to "anywhere".
https://www.youtube.com/watch?v=leNNivaQbDY&t=31s
So I deployed my third app to heroku but to my surprise the app is not working, it's the first time when I get this kind of error:
code=H10 desc="App crashed"
At first I forgot to set my port variable like this: const port = process.env.PORT || 5000;
And then listen to it like this:
server.listen(port, () => {
console.log('Server is runing on port 5000');
});
But even when I set up port variable I still get the same error and I don't know what can cause this error.
2018-10-04T15:12:29.405064+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=m-o-d.herokuapp.com request_id=430f142b-4820-410b-865b-cc6bffae2fa5 fwd="195.12.167.97" dyno= connect= service= status=503 bytes= protocol=https
2018-10-04T15:12:29.654458+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=m-o-d.herokuapp.com request_id=30ff6c29-f7c3-4350-aaff-4bc22f823dd8 fwd="195.12.167.97" dyno= connect= service= status=503 bytes= protocol=https
App works when I run it in my localhost like this: npm start
2018-10-04T17:09:24.933184+00:00 app[web.1]: npm ERR! Failed at the mystery_of_dungeons#1.0.0 start script.
2018-10-04T17:09:24.921760+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:542:15)
2018-10-04T17:09:24.921763+00:00 app[web.1]: at require (internal/module.js:11:18)
2018-10-04T17:09:24.921766+00:00 app[web.1]: at Module._compile (module.js:641:30)
//import modules
var builder = require("botbuilder");
var restify = require("restify");
var menu = require("./menuConfig.json");
var express = require("express");
var request = require("request");
var bodyParser = require("body-parser");
I got this part for ms-Azure connector, and builder.UniversalBot() method for the XXX.dialog() waterflow pattern.
var server = restify.createServer();
server.listen(process.env.port||process.env.PORT||3978, function () {
console.log('%s listening to %s', server.name, server.url);
})
var connector = new builder.ChatConnector({
appId: process.env.MicrosoftAppId,
appPassword: process.env.MicrosoftAppPassword,
})
server.post('/api/messages', connector.listen());
var bot = new builder.UniversalBot(connector)
Then I added second part for Heroku connect and facebook webhook
var app = express();
app.use(bodyParser.urlencoded({extended:false}));
app.use(bodyParser.json());
app.listen((process.env.PORT||5000));
app.get("/",function(req,
res){
res.send("deployed!");
})
app.get("/webhook",function(req,res){
if(req.query["hub.verify_token"]==="process.env.VERIFICATION_TOKEN"){
console.log("Verified webhook");
res.status(200).send(req.query["hub.challenge"]);
}else{
console.error("Verification failed. The tokens do not match");
res.sendStatus(403)
}
})
var mainMenu = menu.main;
var drinkMenu = menu.drink;
var foodMenu = menu.food;
then rest dialog water flow
bot.dialog("/",[
//default dialog
function(session) {
session.send("welcom!!");
session.replaceDialog('mainMenu');
}
]).triggerAction({matches: /^fistUse$/});
.....etc
this is my package.json
{
"name": "baobao_generator_bot",
"version": "1.0.0",
"description": "create baobao generator bot",
"main": "app.js",
"author": {
"name": "orangelion"
},
"license": "ISC",
"scripts": {
"start": "node app.js"
},
"dependencies": {
"body-parser": "^1.18.2",
"botbuilder": "3.14.0",
"express": "^4.16.2",
"mongoose": "^5.0.9",
"request": "^2.83.0",
"restify": "6.3.4"
}
}
I successfully git pushed my program to heroku.
but when I enter heroku open, I got Application error.
Here's the log.
Application Logs
2018-03-07T11:18:55.690635+00:00 app[web.1]: - npm ERR! A complete log of this run can be found in:
2018-03-07T11:18:55.690851+00:00 app[web.1]: - npm ERR! /app/.npm/_logs/2018-03-07T11_18_55_626Z-debug.log
2018-03-07T11:18:55.895218+00:00 heroku[web.1]: - State changed from starting to crashed
2018-03-07T11:18:55.882087+00:00 heroku[web.1]: - Process exited with status 1
2018-03-07T11:46:32.782848+00:00 heroku[router]: - at=error code=H10 desc="App crashed" method=GET path="/" host=immense-falls-15019.herokuapp.com request_id=05e87397-b586-4319-abf6-a51deab37e7b fwd="125.227.255.81" dyno= connect= service= status=503 bytes= protocol=https
2018-03-07T11:46:33.061549+00:00 heroku[router]: - at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=immense-falls-15019.herokuapp.com request_id=5fd3502b-0884-430d-a3a8-9088ab62e2e5 fwd="125.227.255.81" dyno= connect= service= status=503 bytes= protocol=https
2018-03-07T11:47:41.678941+00:00 heroku[router]: - at=error code=H10 desc="App crashed" method=GET path="/" host=immense-falls-15019.herokuapp.com request_id=a203c6a9-b934-4306-823f-00baf6eb6f9d fwd="125.227.255.81" dyno= connect= service= status=503 bytes= protocol=https
2018-03-07T11:47:41.975202+00:00 heroku[router]: - at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=immense-falls-15019.herokuapp.com request_id=22b6bb3e-c5c0-47e6-a4c7-c5b3d1f17b0f fwd="125.227.255.81" dyno= connect= service= status=503 bytes= protocol=https
2018-03-07T11:51:02.393492+00:00 heroku[router]: - at=error code=H10 desc="App crashed" method=GET path="/" host=immense-falls-15019.herokuapp.com request_id=66493288-1511-46dc-9c58-9978ad6ed3d5 fwd="125.227.255.81" dyno= connect= service= status=503 bytes= protocol=https
2018-03-07T11:51:02.708936+00:00 heroku[router]: - at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=immense-falls-15019.herokuapp.com request_id=0f4af933-6501-4966-856a-91e77e504868 fwd="125.227.255.81" dyno= connect= service= status=503 bytes= prot
ocol=https
I've found similar quetion here but didn't get the solution of my problem.
Is there a way not too complicated to run a msbot-frame-work chatbot
on heroku? Or I have to choose : give up to use ms-bot-framework or use Azure?
And any other cloud service is recommended?
I am trying to run a Node.js application on Heroku, but am seeing R10 and H10 errors.
Here are the Heroku logs:
(Note: in my Heroku logs I came accross this gitAccess#0.0.0 start /app
should it be app.js but I have declared it properly in 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>
My app.Js file looks like this
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;
and this is my package.json file
{
"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"
}
}
also I have set up my Procfile as web : node app.js
Where can I be going wrong.
Edit : My server.Js files
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;
It looks like your error is because you're requiring node modules which are not in your package.json file (and therefore not being imported into your app's dyno when Heroku stands it up).
For example, underscore-node.
As a habit, I always do npm install <modulename> --save to make sure it gets into the package.json.