15

This may be a stupid question, but I'm wondering what platform I should use to deploy my Angular.js app? I tried using Heroku but got a "no Cedar-supported app detected" error. Any thoughts?

UPDATE

I'm trying to serve this to heorku as a Node.js application, but still can't seem to get it working. There's a web-server.js file in the root directory of my application and I reference it in my Procfile here:

web: node web-server.js

And here's my package.json file, also in the root directory:

{
"name": "medicare-data",
"version": "0.0.1",
"dependencies": {
},
"engines": {
    "node": "0.10.x",
    "npm": "1.2.x"
},
"respository": "medicare-data",
"author": "sararob"
}

I'm getting a "slug compilation error" in my heroku logs. Thoughts on why this might not be working?

Sara
  • 2,729
  • 7
  • 22
  • 30
  • Angular is pure javascript and should be platform independent. This Q/A may help: http://stackoverflow.com/questions/13926419/heroku-for-node-heroku-push-rejected-no-cedar-supported-app-detected – Dan May 21 '13 at 16:10
  • The title of the question should be: "How do I upload any file to Heroku" ;-) – TheHippo May 21 '13 at 16:19

3 Answers3

11

You can run an Angular app on heroku if it is served as a node.js application. Usually, when you start working with Angular seed, there is already a node webserver script in the project. I believe if there is a package.json file in the root, heroku will detect and run it as a node.js application. I'll come back and update this answer with more detail shortly.

UPDATE

From the Heroku docs (and I am no expert), it has this passage after the deploy section: https://devcenter.heroku.com/articles/nodejs#visit-your-application

which basically tells you to make sure you have one dyno running. You can do that either through the web app under the settings of your app or you can run this:

$ heroku ps:scale web=1

To see if the process is running, do

$ heroku ps
=== web: `node web.js`
web.1: up for 10s
Sam McAfee
  • 10,057
  • 15
  • 60
  • 64
  • Thanks Sam, I'm trying to serve it as a node.js application on heroku now but am still getting some errors. See my update above. Any thoughts? – Sara May 21 '13 at 22:01
4

I bet if you look at your logs you'll see something like this:

2013-08-26T12:51:18.257006+00:00 heroku[web.1]: Starting process with command `node scripts/web-server.js`
2013-08-26T12:51:19.109974+00:00 app[web.1]: Http Server running at http://localhost:8000/
2013-08-26T12:51:34.369092+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path=/ host=cmwidget.herokuapp.com fwd="77.101.66.230" dyno= connect= service= status=503 bytes=
2013-08-26T12:52:19.445974+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

It means that your Angular seed app is using it's own port (8000), and Heroku doesn't allow this. You need to relinquish the assignment of the port number to Heroku.

Easily fixed. Modify scripts/web-server.js, and change this:

this.server.listen(port);

...to this:

this.server.listen(process.env.PORT || port);
opyate
  • 5,388
  • 1
  • 37
  • 64
3

I changed this line var DEFAULT_PORT = 8000; into: var DEFAULT_PORT = process.env.PORT || 8000;

..and then it worked. So I believe the reason is that heroku doesn't like your app running on port 8000.

  • Heroku wants to automatically assign the port for each instance, so changing it to `process.env.PORT` allows you to to that. Your local machine will auto-assign a port this way too, so testing local will work the same. –  Feb 13 '15 at 21:57