Skip to content
This repository has been archived by the owner on Jan 11, 2019. It is now read-only.

Can't seem to get app to start on Heroku #12

Closed
michaelryancaputo opened this issue Mar 8, 2015 · 20 comments
Closed

Can't seem to get app to start on Heroku #12

michaelryancaputo opened this issue Mar 8, 2015 · 20 comments
Assignees

Comments

@michaelryancaputo
Copy link

The Supervisor configuration doesn't seem to play nice with Heroku.

@RickWong
Copy link
Owner

RickWong commented Mar 8, 2015

I don't use Heroku. Do you get any error messages?

@michaelryancaputo
Copy link
Author

2015-03-08T15:45:19.993187+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2015-03-08T15:45:19.993504+00:00 app[web.1]: npm ERR! node v0.12.0
2015-03-08T15:45:19.993923+00:00 app[web.1]: npm ERR! npm  v2.5.1
2015-03-08T15:45:19.994222+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2015-03-08T15:45:19.994382+00:00 app[web.1]: npm ERR! bitwatcher@0.0.1 start: `eval 'supervisor dist/server >tmp/supervisor.log 2>&1 & SUPERVISOR_PID=$!';     sleep 1;     kill $SUPERVISOR_PID;`
2015-03-08T15:45:19.994519+00:00 app[web.1]: npm ERR! Exit status 1
2015-03-08T15:45:19.994677+00:00 app[web.1]: npm ERR! 
2015-03-08T15:45:19.994821+00:00 app[web.1]: npm ERR! Failed at the bitwatcher@0.0.1 start script 'eval 'supervisor dist/server >tmp/supervisor.log 2>&1 & SUPERVISOR_PID=$!';     sleep 1;     kill $SUPERVISOR_PID;'.
2015-03-08T15:45:19.994974+00:00 app[web.1]: npm ERR! This is most likely a problem with the bitwatcher package,
2015-03-08T15:45:19.995099+00:00 app[web.1]: npm ERR! not with npm itself.
2015-03-08T15:45:19.995229+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2015-03-08T15:45:19.995374+00:00 app[web.1]: npm ERR!     eval 'supervisor dist/server >tmp/supervisor.log 2>&1 & SUPERVISOR_PID=$!';     sleep 1;     kill $SUPERVISOR_PID;
2015-03-08T15:45:19.995488+00:00 app[web.1]: npm ERR! You can get their info via:
2015-03-08T15:45:19.995618+00:00 app[web.1]: npm ERR!     npm owner ls bitwatcher
2015-03-08T15:45:19.995744+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2015-03-08T15:45:19.998152+00:00 app[web.1]: 
2015-03-08T15:45:20.643048+00:00 heroku[web.1]: Process exited with status 1
2015-03-08T15:45:20.665030+00:00 heroku[web.1]: State changed from starting to crashed
2015-03-08T15:45:21.719448+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=bitwatcher.herokuapp.com request_id=4be4ef58-f83c-42a7-8f04-49338495d5fe fwd="184.148.68.109" dyno= connect= service= status=503 bytes=
2015-03-08T15:45:22.129301+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=bitwatcher.herokuapp.com request_id=76341116-379b-48c6-9586-6f5c8dc5e61e fwd="184.148.68.109" dyno= connect= service= status=503 bytes=
2015-03-08T15:45:22.673869+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=bitwatcher.herokuapp.com request_id=42612294-57c1-4367-ab6f-1a759a49404a fwd="184.148.68.109" dyno= connect= service= status=503 bytes=

@RickWong
Copy link
Owner

RickWong commented Mar 8, 2015

See: cb0a4c6

Instead of the command-line eval + PID-magic the starterkit now uses concurrent(ly). Does it run on Heroku now?

@RickWong RickWong self-assigned this Mar 8, 2015
@lonnen
Copy link

lonnen commented Mar 9, 2015

Heroku will infer that this is a node app from the package.json file and try to run npm start by default. If you add a Procfile you can override this to run something else. There will be an environment variable, PORT that your app is expected to bind shortly after starting.

It's problematic that server.js hardcodes 8000 instead of env.PORT || 8000 or similar.
It's also problematic that npm start runs npm run localhost, which seems relevant only to local development. This could be fixed with a Procfile that did the right thing. Maybe that's best left to the client project as they need it? It probably depends on how you see this project getting deployed in a production setting.

@michaelryancaputo
Copy link
Author

Still getting this error:

2015-03-12T12:17:46.160436+00:00 heroku[web.1]: State changed from crashed to starting
2015-03-12T12:17:49.510297+00:00 heroku[web.1]: Starting process with command `npm start`
2015-03-12T12:17:51.006574+00:00 app[web.1]: Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
2015-03-12T12:17:51.006601+00:00 app[web.1]: Recommending WEB_CONCURRENCY=1
2015-03-12T12:17:51.698939+00:00 app[web.1]:
2015-03-12T12:17:51.698946+00:00 app[web.1]: > bitwatcher@0.0.1 start /app
2015-03-12T12:17:51.698949+00:00 app[web.1]: > sleep 6; concurrent 'supervisor dist/server' 'npm run localhost'
2015-03-12T12:17:51.698950+00:00 app[web.1]:
2015-03-12T12:17:57.730160+00:00 app[web.1]: sh: 1: concurrent: not found
2015-03-12T12:17:57.743679+00:00 app[web.1]: npm ERR! Linux 3.13.0-40-generic
2015-03-12T12:17:57.750214+00:00 app[web.1]:
2015-03-12T12:17:57.738503+00:00 app[web.1]:
2015-03-12T12:17:57.744260+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2015-03-12T12:17:57.744517+00:00 app[web.1]: npm ERR! node v0.12.0
2015-03-12T12:17:57.744930+00:00 app[web.1]: npm ERR! npm  v2.5.1
2015-03-12T12:17:57.745144+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2015-03-12T12:17:57.745364+00:00 app[web.1]: npm ERR! bitwatcher@0.0.1 start: `sleep 6; concurrent 'supervisor dist/server' 'npm run localhost'`
2015-03-12T12:17:57.745754+00:00 app[web.1]: npm ERR! Exit status 127
2015-03-12T12:17:57.745923+00:00 app[web.1]: npm ERR!
2015-03-12T12:17:57.746086+00:00 app[web.1]: npm ERR! Failed at the bitwatcher@0.0.1 start script 'sleep 6; concurrent 'supervisor dist/server' 'npm run localhost''.
2015-03-12T12:17:57.746373+00:00 app[web.1]: npm ERR! This is most likely a problem with the bitwatcher package,
2015-03-12T12:17:57.746520+00:00 app[web.1]: npm ERR! not with npm itself.
2015-03-12T12:17:57.746673+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2015-03-12T12:17:57.746812+00:00 app[web.1]: npm ERR!     sleep 6; concurrent 'supervisor dist/server' 'npm run localhost'
2015-03-12T12:17:57.746969+00:00 app[web.1]: npm ERR! You can get their info via:
2015-03-12T12:17:57.747119+00:00 app[web.1]: npm ERR!     npm owner ls bitwatcher
2015-03-12T12:17:57.747451+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2015-03-12T12:17:57.750472+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2015-03-12T12:17:57.750606+00:00 app[web.1]: npm ERR!     /app/npm-debug.log
2015-03-12T12:17:58.553089+00:00 heroku[web.1]: State changed from starting to crashed
2015-03-12T12:17:58.542021+00:00 heroku[web.1]: Process exited with status 1
2015-03-12T12:17:59.775297+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=bitwatcher.herokuapp.com request_id=1f3eb99c-cd83-4bab-8be7-ab188dff3f89 fwd="184.148.68.109" dyno= connect= service= status=503 bytes=
2015-03-12T12:18:00.362100+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=bitwatcher.herokuapp.com request_id=28189cc9-d21a-4de2-9be9-bb07e70d1602 fwd="184.148.68.109" dyno= connect= service= status=503 bytes=
2015-03-12T12:18:01.269384+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=bitwatcher.herokuapp.com request_id=bbc56db3-5059-41a5-8b30-a6c89e3a34f5 fwd="184.148.68.109" dyno= connect= service= status=503 bytes=

@lonnen I've got the proper env port set up on my config.

This is the repo i'm trying to deploy if you're interested: https://github.com/michaelryancaputo/bitwatcher

@RickWong
Copy link
Owner

Recently added concurrently as a global npm dependency. Try installing it first with npm install -g concurrently

@michaelryancaputo
Copy link
Author

I've done that as per the commit you referenced above

@RickWong
Copy link
Owner

That's weird then. It shouldn't say sh: 1: concurrent: not found if concurrently is installed. Or does Heroku not allow it?

@stefanoTron
Copy link

Was anyone able to successfully deploy it on Heroku?
I'm getting the following with the latest version:

npm ERR! Linux 3.13.0-77-generic
npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "run" "build"
npm ERR! node v5.7.1
npm ERR! npm  v3.6.0
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! react-isomorphic-starterkit@5.3.1 build: `concurrently "npm run build-server" "npm run build-client"`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the react-isomorphic-starterkit@5.3.1 build script 'concurrently "npm run build-server" "npm run build-client"'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the react-isomorphic-starterkit package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     concurrently "npm run build-server" "npm run build-client"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs react-isomorphic-starterkit
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls react-isomorphic-starterkit
npm ERR! There is likely additional logging output above.

Some help would be very much appreciated :)

@lonnen
Copy link

lonnen commented Mar 6, 2016

concurrently is listed in devDependencies. Heroku doesn't install those by default. You can alter this behavior with an env var that NPM will pick up. Try setting:

heroku config:set NPM_CONFIG_PRODUCTION=false

@stefanoTron
Copy link

Hi @lonnen
Thanks for your reply, I got the right dependencies now. But I ran in another issue. Heroku gives me the following:

==> 🌎  Go to http://localhost:8000
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
Stopping process with SIGKILL
Process exited with status 137
State changed from starting to crashed

http://localhost:8000 is obviously not correct while deploying on Heroku.
I added a console.log of process.env.PORT which results as undefined

Any idea what could cause this?

I have the following env vars set:

NPM_CONFIG_PRODUCTION=true
NODE_ENV=production
NODE_MODULES_CACHE=true

Thanks

@lonnen
Copy link

lonnen commented Mar 11, 2016

You're hitting the same issue I did earlier. Heroku exposes a $PORT value to you (arbitrary and generated at runtime, so you can't hard code it). You need to modify the app to use env.PORT || 8000 or similar.

@stefanoTron
Copy link

I have this line

const port = process.env.PORT || 8000;

But its value is undefined
Kinda looks like Heroku fails to inject his environment variables...

Could you share your config?

@lonnen
Copy link

lonnen commented Mar 14, 2016

I'm not running this anymore so I have nothing to share. You can find a bunch of node services doing the same -- see hubot's use of process.env.PORT on line https://github.com/github/hubot/blob/master/src/robot.coffee#L416

I'd be very surprised if the problem was Heroku not injecting the env var. You could try to log the following:

for (var key in process.env) {
 console.log(process.env[key]);
}

@stefanoTron
Copy link

Tried this already, but it only returns the NODE_ENV var (which contains production).
I must be doing something wrong somewhere else.
Thanks for your help anyway!

@lonnen
Copy link

lonnen commented Mar 14, 2016

@littletower I'm curious -- what is the process name you're using in your Procfile? Only the web process will have a port exposed to it.

@stefanoTron
Copy link

I have this

web: npm run build; npm run start

@lonnen
Copy link

lonnen commented Mar 14, 2016

I believe you want it to be a single command.

web: npm run build && npm run start

@lonnen
Copy link

lonnen commented Mar 14, 2016

On second thought, you probably don't want to run build here unless you have to do it. You want to keep time to startup the process short. You probably want npm run build to be postinstall instead. See -- https://devcenter.heroku.com/articles/nodejs-support

@stefanoTron
Copy link

thanks, so now I have web: npm run start. I also added a postinstall with the npm run build command, it now builds on commit which is nice, but that does not fix the problem with the env vars... :(

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants