2

I'm using Yeoman/bower/grunt to build an angular app. The app runs perfectly on foreman. In my search of similar questions on stack most other people just forgot to create their Procfile or had mistakes in their app.js which ran the app. But I have both of those and I can't figure out what's wrong with them, such that foreman works and not heroku. When I deploy to heroku and open it I get this in the log:

2013-10-02T19:33:56.159151+00:00 heroku[api]: Deploy b417d22 by richardadavila@gmail.com
2013-10-02T19:33:56.202052+00:00 heroku[api]: Release v10 created by     richardadavila@gmail.com
2013-10-02T20:38:51.350572+00:00 heroku[web.1]: Idling
2013-10-02T20:38:57.626159+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2013-10-02T20:39:02.097317+00:00 heroku[web.1]: State changed from up to down
2013-10-02T20:39:02.079612+00:00 heroku[web.1]: Process exited with status 143
2013-10-02T22:00:00.360769+00:00 heroku[web.1]: Unidling
2013-10-02T22:00:00.361135+00:00 heroku[web.1]: State changed from down to starting
2013-10-02T22:00:04.049439+00:00 heroku[web.1]: Starting process with command `node app.js`
2013-10-02T22:00:06.128657+00:00 app[web.1]: server started 40741
2013-10-02T22:00:06.164522+00:00 heroku[web.1]: State changed from starting to up
2013-10-02T22:00:07.479644+00:00 heroku[router]: at=info method=GET path=/ host=rickydavila-kpopbetter-s.herokuapp.com fwd="71.144.19.194" dyno=web.1 connect=9ms service=30ms status=404 bytes=22

No error (I probably don't fully understand the log), it just kills the app.

My Procfile says: "node app.js"

My app.js file that creates an express server to run the app is:

var express = require('express');

var path = require('path');

var app = express();

app.configure(function(){
  'use strict';
  app.use(express.bodyParser());
  app.use(express.static(path.join(__dirname, 'dist')));
});

var port = process.env.PORT || 5000;

app.listen(port, function() {
    'use strict';
    console.log('server started '+port);
});

Grunt builds the app to my dist folder which I reference above. Any clear mistakes above? When I open the heroku app url, the page states: Cannot GET /

Oh I also have scaled the dynos as some other questions failed to do. And to my knowledge I'm not hardcoding the port.

rickydav
  • 133
  • 2
  • 9

1 Answers1

10

Figured it out. Always check your .gitignore file! I forgot to remove dist from the file and it hadn't been committed or pushed to heroku.

rickydav
  • 133
  • 2
  • 9
  • 1
    Thank you so much, like you I've been searching everywhere for a solution. I was hoping to set this up so I wouldn't need to commit dist to the repo, just have travis build and deploy it from my source. Do you have any thoughts on how to do that or if that's a good/bad idea? – Joseph Spens Dec 12 '13 at 03:27
  • Don't know anything about Travis, but if you're asking how to not commit dist but have only dist deploy to heroku then search how to do that with git, I remember seeing a question and answer about that. Def possible and lots of people do it: i did a quick search and saw these: [link] (http://stackoverflow.com/questions/18183872/how-to-keep-a-deployment-repo-for-heroku-within-a-development-git-repo-and-keep), [link](http://stackoverflow.com/questions/18868769/deploy-git-subdirectory-on-heroku). Hope that is helpful – rickydav Dec 13 '13 at 22:58
  • Thanks! I've been using the subtree method, the first one with dist on its own branch is interesting. I think I can manipulate my build process to do one of these automatically. – Joseph Spens Dec 14 '13 at 00:01
  • This x1000000. Wasted so much time trying to figure why heroku wouldn't serve my public directory. It was added to `.gitignore`. Doh! – Liam George Betsworth Jul 06 '16 at 10:32