I'm trying to create a simple chat application, but heroku is giving me errors:
2014-05-09T20:19:43.315159+00:00 heroku[api]: Enable Logplex by zwhitchcox#gmail.com
2014-05-09T20:19:43.315241+00:00 heroku[api]: Release v2 created by zwhitchcox#gmail.com
2014-05-09T20:20:06+00:00 heroku[slug-compiler]: Slug compilation started
2014-05-09T20:20:25.635919+00:00 heroku[api]: Release v3 created by zwhitchcox#gmail.com
2014-05-09T20:20:25.532933+00:00 heroku[api]: Scale to web=1 by zwhitchcox#gmail.com
2014-05-09T20:20:25.635919+00:00 heroku[api]: Deploy 62543a1 by zwhitchcox#gmail.com
2014-05-09T20:20:25+00:00 heroku[slug-compiler]: Slug compilation finished
2014-05-09T20:20:26.536745+00:00 heroku[api]: Scale to web=1 by zwhitchcox#gmail.com
2014-05-09T20:20:27.704168+00:00 heroku[web.1]: Starting process with command `node server.js`
2014-05-09T20:20:29.653123+00:00 app[web.1]: info: socket.io started
2014-05-09T20:21:29.273275+00:00 heroku[web.1]: State changed from starting to crashed
2014-05-09T20:21:29.274054+00:00 heroku[web.1]: State changed from crashed to starting
2014-05-09T20:21:27.960123+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2014-05-09T20:21:27.960449+00:00 heroku[web.1]: Stopping process with SIGKILL
2014-05-09T20:21:29.258964+00:00 heroku[web.1]: Process exited with status 137
2014-05-09T20:21:32.343694+00:00 app[web.1]: info: socket.io started
2014-05-09T20:21:31.092312+00:00 heroku[web.1]: Starting process with command `node server.js`
2014-05-09T20:21:44.023410+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path=/ host=boiling-wave-8331.herokuapp.com request_id=19d30ac7-a101-4ace-b993-89d02092be0f fwd="50.193.187.85" dyno= connect= service= status=503 bytes=
2014-05-09T20:22:34.214614+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=boiling-wave-8331.herokuapp.com request_id=09ffb0f3-2c08-4d12-8b9c-37fa4c112680 fwd="50.193.187.85" dyno= connect= service= status=503 bytes=
2014-05-09T20:22:32.984322+00:00 heroku[web.1]: State changed from starting to crashed
2014-05-09T20:22:32.972699+00:00 heroku[web.1]: Process exited with status 137
2014-05-09T20:22:31.694958+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2014-05-09T20:22:31.695682+00:00 heroku[web.1]: Stopping process with SIGKILL
2014-05-09T20:26:46.594041+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=boiling-wave-8331.herokuapp.com request_id=7823d4c1-f102-4e64-b47f-c50e5c9452c4 fwd="50.193.187.85" dyno= connect= service= status=503 bytes=
2014-05-09T20:26:46.280531+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=boiling-wave-8331.herokuapp.com request_id=1b4b66ba-f5f5-4fca-affc-06b3b6f3dc38 fwd="50.193.187.85" dyno= connect= service= status=503 bytes=
2014-05-09T20:27:21.798690+00:00 heroku[api]: Scale to web=1 by zwhitchcox#gmail.com
2014-05-09T20:27:32.718961+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=boiling-wave-8331.herokuapp.com request_id=ca1e9a7a-b7c8-4c67-a064-e069e0940dd6 fwd="50.193.187.85" dyno= connect= service= status=503 bytes=
2014-05-09T20:27:33.050677+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=boiling-wave-8331.herokuapp.com request_id=50a8f3e7-a60a-4f76-8eb4-7b17c9e26155 fwd="50.193.187.85" dyno= connect= service= status=503 bytes=
However, my application works whenever I use foreman start.
This is my server code:
var express = require('express'),
app = express(),
server = require('http').createServer(app),
io = require('socket.io').listen(server),
port = 8090,
chatClients = new Object();
server.listen(port);
app.get('/', function (req, res) {
res.sendfile(__dirname+'/index.html');
});
io.sockets.on("connection", function(socket) {
socket.on('message', function(data) {
io.sockets.emit('receiveMessage',{yourMessage:data.message});
});
});
This is my index.html code:
<div id="messages"></div>
<input id="message">
<button id="submit">send</button>
<script type="text/javascript" src="/socket.io/socket.io.js"></script>
<script>
socket = null;
socket = io.connect();
socket.on('receiveMessage', function(data) {
var message = document.createElement('p');
message.innerHTML = data.yourMessage;
document.getElementById('messages').appendChild(message);
});
document.getElementById('submit').onclick = function() {
socket.emit('message',{message:document.getElementById('message').value});
}
</script>
Can anyone please lend me a hand?
Heroku assigns port randomly, and you need to make sure to separate out your environments.
var express = require('express'),
app = express(),
server = require('http').createServer(app),
io = require('socket.io').listen(server),
port = (process.env.NODE_ENV == 'production') ? process.env.PORT : 8090,
chatClients = new Object();
server.listen(port);
app.get('/', function (req, res) {
res.sendfile(__dirname+'/index.html');
});
io.sockets.on("connection", function(socket) {
socket.on('message', function(data) {
io.sockets.emit('receiveMessage',{yourMessage:data.message});
});
});
Then do: heroku config:set NODE_ENV=production
Read more about it here: https://devcenter.heroku.com/articles/nodejs-support#environment
Related
How can I solve this problem?
I am trying to deploy my app on Heroku but got it.
2022-08-23T16:57:35.218184+00:00 app[web.1]: [31m[nodemon] app crashed - waiting for file
changes before starting...[39m
2022-08-23T16:58:32.598554+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed
to bind to $PORT within 60 seconds of launch
2022-08-23T16:58:32.806114+00:00 heroku[web.1]: Stopping process with SIGKILL
2022-08-23T16:58:32.868193+00:00 app[web.1]: Error waiting for process to terminate: No child
processes
2022-08-23T16:58:32.994998+00:00 heroku[web.1]: Process exited with status 22
2022-08-23T16:58:33.366388+00:00 heroku[web.1]: State changed from starting to crashed
2022-08-23T16:58:42.029599+00:00 heroku[router]: at=error code=H10 desc="App crashed"
method=GET path="/" host=m-store-web-app.herokuapp.com request_id=15788032-7844-4a3e-86af-
13551b3df1fe fwd="134.17.150.128" dyno= connect= service= status=503 bytes= protocol=https
2022-08-23T16:58:42.235272+00:00 heroku[router]: at=error code=H10 desc="App crashed"
method=GET path="/favicon.ico" host=m-store-web-app.herokuapp.com request_id=03b67b8a-429e-
4a52-8a82-62ba41a92d29 fwd="134.17.150.128" dyno= connect= service= status=503 bytes=
protocol=https
My index.js for server
app.use(express.static(path.join(__dirname + "/public")));
const start = async () => {
try {
await mongoose.connect(process.env.DB_URL, {
useNewUrlParser: true,
useUnifiedTopology: true,
});
app.listen(PORT, console.log(`Server running on port ${PORT}`));
} catch (e) {
console.log(e);
}
};
start();
I don't have Procfile if it's important
I uploaded telegram bot with webhook on Heroku but the app crashes.
I checked Heroku support but nothing helped, so I really do not know what might be the problem.
I set telegram webhook in the following way:
class Bot {
constructor(token) {
this.client = new TelegramBotClient(token,
{ webhook: { port: process.env.PORT || 5000 } }
);
this.client.setWebHook(`${config.heroku_app}/bot${token}`);
}
My Procfile:
web: node main.js
package.json contains
"scripts": {
"start": "node main.js"
}
There are no long running build processes happen during a deploy, so that also shouldn't be the cause.
Error logs:
2022-06-01T12:52:12.810740+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2022-06-01T12:52:12.848491+00:00 heroku[web.1]: Stopping process with SIGKILL
2022-06-01T12:52:13.000433+00:00 heroku[web.1]: Process exited with status 137
2022-06-01T12:52:13.090750+00:00 heroku[web.1]: State changed from starting to crashed
2022-06-01T12:52:15.688412+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=POST path="/{token}" host=notification-tg-bot.herokuapp.com request_id=7859b4ef-2a3d-4e61-8d8d-60513252502c fwd="91.108.6.71" dyno= connect= service= status=503 bytes= protocol=https
2022-06-01T12:53:15.778224+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=POST path="/{token}" host=notification-tg-bot.herokuapp.com request_id=aa04c555-c4c6-42d8-b254-bc6588b533d2 fwd="91.108.6.71" dyno= connect= service= status=503 bytes= protocol=https
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 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
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.