heroku[web.1]: Process exited with status 137 - node.js

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

Related

Why is my app crashing with an R10 error?

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

How can I fix my heroku app and prevent it from crashing? at=error code=H10 desc="App crashed" method=GET path="/"

My app has always been working well, but suddenly it started crashing when I tried pushing to heroku.
Here are the logs:
2019-07-29T10:15:28.986142+00:00 app[web.1]: npm ERR!
2019-07-29T10:15:28.990123+00:00 app[web.1]: npm ERR! Failed at the jobdirecto#1.0.0 start script.
2019-07-29T10:15:28.990128+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-07-29T10:15:29.002123+00:00 app[web.1]:
2019-07-29T10:15:29.002127+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-07-29T10:15:29.002129+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-07-29T10_15_28_987Z-debug.log
2019-07-29T10:15:29.097390+00:00 heroku[web.1]: State changed from starting to crashed
2019-07-29T10:15:29.077730+00:00 heroku[web.1]: Process exited with status 1
2019-07-29T14:10:35.913876+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=vast-eyrie-16248.herokuapp.com request_id=8690ecb0-5c93-41f1-b861-1e2ecc194863 fwd="87.191.57.50" dyno= connect= service= status=503 bytes= protocol=https
2019-07-29T14:10:36.826030+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=vast-eyrie-16248.herokuapp.com request_id=df653f75-9e1f-46ab-a5ed-e867a8c95687 fwd="87.191.57.50" dyno= connect= service= status=503 bytes= protocol=https
Here is the node configuration:
if (process.env.NODE_ENV != "production") {
app.use(
"/bundle.js",
require("http-proxy-middleware")({
target: "http://localhost:8081/"
})
);
} else {
app.use("/bundle.js", (req, res) => res.sendFile(`${__dirname}/bundle.js`));
}
app.listen(process.env.PORT || 8080);
Please help me as I've been days trying to solve this and I still can't figure out a solution.

Application error after succeeded Heroku Build (Node + React App)

I created an React app (using CRA) with Nodejs backend. Now I tried hosting it. (I've hosted few apps with same stack but didn't faced any issues).
I'm starting both Nodejs and React app using concurrently module with npm run dev.
But this time I'm getting an error and I can't figure out why.
This is what I get when I go the link.
Application error
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details.
index.js
const express = require('express');
const routes = require('./routes');
const app = express();
const port = 5000 || process.env.PORT;
routes(app);
if(process.env.NODE_ENV === 'production'){
app.use(express.static('client/build'));
const path = require('path');
app.get("*", (req,res) => {
res.sendFile(path.resolve(__dirname,'client','build','index.html'));
})
}
app.listen(port, () => console.log(`Server is running on port ${port}`));
package.json
{
"name": "check-market",
"version": "1.0.0",
"description": "This is a react-nodejs based crypto market checking app",
"main": "index.js",
"scripts": {
"start": "node index.js",
"server": "nodemon index.js",
"test": "echo \"Error: no test specified\" && exit 1",
"client": "npm run start --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\"",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
},
"author": "abcd",
"license": "ISC",
"dependencies": {
"concurrently": "^3.5.1",
"cryptocoins-icons": "^2.7.0",
"express": "^4.16.2",
"node-fetch": "^2.0.0",
"nodemon": "^1.14.12"
}
}
heroku logs
2018-04-05T13:41:49.283535+00:00 app[web.1]: [1]2018-04-05T13:41:49.560174+00:00 app[web.1]: [0] Server is running on port 5000
2018-04-05T13:41:51.049613+00:00 app[web.1]: [1] Starting the development server...
2018-04-05T13:41:51.049625+00:00 app[web.1]: [1]
2018-04-05T13:41:51.202463+00:00 heroku[web.1]: State changed from starting to up
2018-04-05T13:42:00.969286+00:00 app[web.1]: [1] Compiled with warnings.
2018-04-05T13:42:00.969303+00:00 app[web.1]: [1]
2018-04-05T13:42:00.969584+00:00 app[web.1]: [1] ./src/components/currency_main.js
2018-04-05T13:42:00.969587+00:00 app[web.1]: [1] Line 49: Expected to return a value in arrow function array-callback-return
2018-04-05T13:42:00.969588+00:00 app[web.1]: [1]
2018-04-05T13:42:00.969590+00:00 app[web.1]: [1] Search for the keywords to learn more about each warning.
2018-04-05T13:42:00.969593+00:00 app[web.1]: [1] To ignore, add // eslint-disable-next-line to the line before.
2018-04-05T13:42:00.969594+00:00 app[web.1]: [1]2018-04-05T13:42:17.377067+00:00 heroku[router]: at=info method=GET path="/" host=cryptic-hollows-53642.herokuapp.com request_id=fa334992-ebb7-4a38-8c2d-e5c09849dcef fwd="112.134.75.196" dyno=web.1 connect=1ms service=13ms status=200 bytes=219 protocol=https
2018-04-05T13:42:18.397503+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=cryptic-hollows-53642.herokuapp.com request_id=e716c9cb-e910-4f98-8346-4195c6d623ca fwd="112.134.75.196" dyno=web.1 connect=0ms service=7ms status=200 bytes=219 protocol=https
2018-04-05T13:44:47.000000+00:00 app[api]: Build started by user thidasaone#gmail.com
2018-04-05T13:44:47.000000+00:00 app[api]: Build succeeded
2018-04-05T13:46:08.491686+00:00 app[api]: Deploy 0ae9d4f3 by user thidasaone#gmail.com2018-04-05T13:46:08.491686+00:00 app[api]: Release v8 created by user thidasaone#gmail.com2018-04-05T13:46:10.417551+00:00 heroku[web.1]: Restarting
2018-04-05T13:46:10.418403+00:00 heroku[web.1]: State changed from up to starting2018-04-05T13:46:12.169322+00:00 heroku[web.1]: Stopping all processes with SIGTERM2018-04-05T13:46:12.258942+00:00 heroku[web.1]: Process exited with status 143
2018-04-05T13:46:17.859328+00:00 heroku[web.1]: Starting process with command `npm run dev`2018-04-05T13:46:20.219087+00:00 app[web.1]:2018-04-05T13:46:20.219128+00:00 app[web.1]: > check-market#1.0.0 dev /app
2018-04-05T13:46:20.219130+00:00 app[web.1]: > concurrently "npm run server" "npm run client"2018-04-05T13:46:20.219132+00:00 app[web.1]:2018-04-05T13:46:20.817238+00:00 app[web.1]: [0]
2018-04-05T13:46:20.817262+00:00 app[web.1]: [0] > check-market#1.0.0 server /app
2018-04-05T13:46:20.817265+00:00 app[web.1]: [0] > nodemon index.js
2018-04-05T13:46:20.817267+00:00 app[web.1]: [0]
2018-04-05T13:46:20.865621+00:00 app[web.1]: [1]
2018-04-05T13:46:20.865626+00:00 app[web.1]: [1] > check-market#1.0.0 client /app
2018-04-05T13:46:20.865635+00:00 app[web.1]: [1] > npm run start --prefix client
2018-04-05T13:46:20.865636+00:00 app[web.1]: [1]
2018-04-05T13:46:21.154092+00:00 app[web.1]: [0] [nodemon] 1.14.12
2018-04-05T13:46:21.155353+00:00 app[web.1]: [0] [nodemon] to restart at any time, enter `rs`
2018-04-05T13:46:21.155695+00:00 app[web.1]: [0] [nodemon] watching: *.*
2018-04-05T13:46:21.156422+00:00 app[web.1]: [0] [nodemon] starting `node index.js`
2018-04-05T13:46:21.225033+00:00 app[web.1]: [1]
2018-04-05T13:46:21.225037+00:00 app[web.1]: [1] > client#0.1.0 start /app/client
2018-04-05T13:46:21.225039+00:00 app[web.1]: [1] > react-scripts start
2018-04-05T13:46:21.225041+00:00 app[web.1]: [1]
2018-04-05T13:46:21.390693+00:00 app[web.1]: [0] Server is running on port 5000
2018-04-05T13:46:22.929315+00:00 app[web.1]: [1] [HPM] Proxy created: function (pathname) {
2018-04-05T13:46:22.929329+00:00 app[web.1]: [1] return mayProxy(pathname) && pathname.match(context);
2018-04-05T13:46:22.929331+00:00 app[web.1]: [1] } -> http://localhost:5000
2018-04-05T13:46:22.940428+00:00 app[web.1]: [1] Starting the development server...
2018-04-05T13:46:22.940431+00:00 app[web.1]: [1]
2018-04-05T13:46:23.520069+00:00 heroku[web.1]: State changed from starting to up
2018-04-05T13:46:31.231306+00:00 heroku[router]: at=info method=GET path="/" host=cryptic-hollows-53642.herokuapp.com request_id=ec7762d5-3d9d-4512-96bf-5e51fd57e531 fwd="112.134.75.196" dyno=web.1 connect=1ms service=35ms status=304 bytes=150 protocol=https
2018-04-05T13:46:32.041938+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=cryptic-hollows-53642.herokuapp.com request_id=51901fca-b454-4e15-891f-54157d6ecffa fwd="112.134.75.196" dyno=web.1 connect=1ms service=74ms status=304 bytes=150 protocol=https
2018-04-05T13:46:34.656623+00:00 app[web.1]: [1]
2018-04-05T13:46:34.656609+00:00 app[web.1]: [1] Compiled with warnings.
2018-04-05T13:46:34.656627+00:00 app[web.1]: [1] Line 49: Expected to return a value in arrow function array-callback-return
2018-04-05T13:46:34.656629+00:00 app[web.1]: [1]
2018-04-05T13:46:34.656650+00:00 app[web.1]: [1] Search for the keywords to learn more about each warning.
2018-04-05T13:46:34.656625+00:00 app[web.1]: [1] ./src/components/currency_main.js
2018-04-05T13:46:34.656652+00:00 app[web.1]: [1] To ignore, add // eslint-disable-next-line to the line before.
2018-04-05T13:46:34.656654+00:00 app[web.1]: [1]
2018-04-05T13:47:01.000000+00:00 app[api]: Build started by user thidasaone#gmail.com
2018-04-05T13:48:18.696342+00:00 heroku[router]: at=info method=GET path="/" host=cryptic-hollows-53642.herokuapp.com request_id=9b941ec9-ac57-465f-8270-ff6b576e7a7e fwd="112.134.75.196" dyno=web.1 connect=1ms service=4ms status=304 bytes=150 protocol=https
2018-04-05T13:48:19.715353+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=cryptic-hollows-53642.herokuapp.com request_id=9dce4cdb-3251-4371-a6dc-17f5157c4c91 fwd="112.134.75.196" dyno=web.1 connect=1ms service=4ms status=200 bytes=219 protocol=https
2018-04-05T13:48:23.281435+00:00 heroku[web.1]: Restarting
2018-04-05T13:48:23.283219+00:00 heroku[web.1]: State changed from up to starting
2018-04-05T13:48:24.367174+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2018-04-05T13:48:24.460758+00:00 heroku[web.1]: Process exited with status 143
2018-04-05T13:48:22.235400+00:00 app[api]: Deploy f9c11456 by user thidasaone#gmail.com
2018-04-05T13:48:22.235400+00:00 app[api]: Release v9 created by user thidasaone#gmail.com
2018-04-05T13:47:01.000000+00:00 app[api]: Build succeeded
2018-04-05T13:48:31.022921+00:00 heroku[web.1]: Starting process with command `npm start`
2018-04-05T13:48:32.988916+00:00 app[web.1]:
2018-04-05T13:48:32.988939+00:00 app[web.1]: > check-market#1.0.0 start /app
2018-04-05T13:48:32.988941+00:00 app[web.1]: > node index.js
2018-04-05T13:48:32.988943+00:00 app[web.1]:
2018-04-05T13:48:33.185499+00:00 app[web.1]: Server is running on port 5000
2018-04-05T13:49:31.116916+00:00 app[web.1]: Error waiting for process to terminate: No child processes
2018-04-05T13:49:31.093326+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 secondsof launch
2018-04-05T13:49:31.093493+00:00 heroku[web.1]: Stopping process with SIGKILL
2018-04-05T13:49:31.174105+00:00 heroku[web.1]: Process exited with status 22
2018-04-05T13:49:31.188588+00:00 heroku[web.1]: State changed from starting to crashed
2018-04-05T13:49:31.190801+00:00 heroku[web.1]: State changed from crashed to starting
2018-04-05T13:49:41.680073+00:00 heroku[web.1]: Starting process with command `npm start`
2018-04-05T13:49:44.021163+00:00 app[web.1]:
2018-04-05T13:49:44.021180+00:00 app[web.1]: > check-market#1.0.0 start /app
2018-04-05T13:49:44.021181+00:00 app[web.1]: > node index.js
2018-04-05T13:49:44.021183+00:00 app[web.1]:
2018-04-05T13:49:44.261412+00:00 app[web.1]: Server is running on port 5000
2018-04-05T13:50:24.659139+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=cryptic-hollows-53642.herokuapp.com request_id=19ee5172-d09e-4a14-bec5-7332c5b8b572 fwd="112.134.75.196" dyno= connect= service= status=503 bytes= protocol=https
2018-04-05T13:50:42.173853+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 secondsof launch
2018-04-05T13:50:42.173971+00:00 heroku[web.1]: Stopping process with SIGKILL
2018-04-05T13:50:42.278113+00:00 heroku[web.1]: Process exited with status 137
2018-04-05T13:50:42.292645+00:00 heroku[web.1]: State changed from starting to crashed
2018-04-05T13:50:44.109644+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=cryptic-hollows-53642.herokuapp.com request_id=457aceaf-7149-4cd8-aaf0-1e9746c2e7a9 fwd="112.134.75.196" dyno= connect= service= status=503 bytes= protocol=https
2018-04-05T13:50:46.073884+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=cryptic-hollows-53642.herokuapp.com request_id=6d2ed2ed-a2dc-4b77-80f1-099d442e16db fwd="112.134.75.196" dyno= connect= service= status=503 bytes= protocol=https
2018-04-05T13:50:55.112767+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=cryptic-hollows-53642.herokuapp.com request_id=51e6ee29-3f28-4dc1-bc69-b58604b6524b fwd="112.134.75.196" dyno= connect= service= status=503 bytes= protocol=https
2018-04-05T13:51:02.307944+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=cryptic-hollows-53642.herokuapp.com request_id=5e366ae1-6d66-4015-85ad-e407316d083f fwd="112.134.75.196" dyno= connect= service= status=503 bytes= protocol=https
2018-04-05T13:51:24.537650+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=cryptic-hollows-53642.herokuapp.com request_id=8483caf1-1e99-4735-a16e-8df0d09b3d20 fwd="112.134.75.196" dyno= connect= service= status=503 bytes= protocol=https
2018-04-05T13:51:27.770178+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=cryptic-hollows-53642.herokuapp.com request_id=28e8927c-21ac-44c5-84e5-093f55c95aeb fwd="112.134.75.196" dyno= connect= service= status=503 bytes= protocol=https
As I read in heroku logs, I know there's an issue (as it mentions). But I can't figure out what it is as what I've followed the same steps as before (same as I hosted other apps on Heroku)
Can anyone tell me what have I done wrong ?
P.S :
I've checked this and added Procfile and then I got an issue with React App saying Invalid Header File . So I removed it (as Heroku has made the process automatically sometime after the post)
And I checked with this as well but I don't think it'll be any help.
Try adding the config vars into your heroku app by going through
Your app => Settings => Reveal Config vars => Add PORT 5000 in it
I had the same exact issue, I have added the PORT 5000 as mentioned above, but it alone didn't resolve my issue.
Anyway by checking the build logs, I found the following error:
Error: Configuration property "mongoURI" is not defined
The production.json file was in .gitignore file, and by removing it from .gitignore and pushing it to Heroku the issue was resolved.

Heroku errors while deploying Node.js application

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.

Foreman start works, but heroku.app doesn't

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

Resources