meanjs / mean

MEAN.JS - Full-Stack JavaScript Using MongoDB, Express, AngularJS, and Node.js -
http://meanjs.org
MIT License
4.87k stars 1.98k forks source link

Heroku deployment problem #43

Closed MichaelJCole closed 10 years ago

MichaelJCole commented 10 years ago

Hi, I'm getting a crash on my Heroku deployment. I noticed in another issue that you mentioned the demo works on Heroku. What am I missing?

2014-05-03T01:47:24+00:00 heroku[slug-compiler]: Slug compilation started
2014-05-03T01:48:02+00:00 heroku[slug-compiler]: Slug compilation finished
2014-05-03T01:48:02.327850+00:00 heroku[web.1]: State changed from crashed to starting
2014-05-03T01:48:02.118577+00:00 heroku[api]: Deploy 06b5253 by heroku@michaelcole.com
2014-05-03T01:48:02.118666+00:00 heroku[api]: Release v8 created by heroku@michaelcole.com
2014-05-03T01:48:06.357371+00:00 app[web.1]: warn:    --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
2014-05-03T01:48:06.356375+00:00 app[web.1]: warn:    --minUptime not set. Defaulting to: 1000ms
2014-05-03T01:48:07.042968+00:00 app[web.1]: Express app started on port 41178
2014-05-03T01:48:07.044926+00:00 app[web.1]: events.js:72
2014-05-03T01:48:07.044772+00:00 app[web.1]: 
2014-05-03T01:48:07.045148+00:00 app[web.1]:         throw er; // Unhandled 'error' event
2014-05-03T01:48:07.045150+00:00 app[web.1]:               ^
2014-05-03T01:48:07.047359+00:00 app[web.1]:     at Socket.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:512:10)
2014-05-03T01:48:07.047361+00:00 app[web.1]:     at Socket.EventEmitter.emit (events.js:95:17)
2014-05-03T01:48:07.047350+00:00 app[web.1]: Error: failed to connect to [localhost:27017]
2014-05-03T01:48:07.047353+00:00 app[web.1]:     at null.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:553:74)
2014-05-03T01:48:07.047354+00:00 app[web.1]:     at EventEmitter.emit (events.js:106:17)
2014-05-03T01:48:07.047356+00:00 app[web.1]:     at null.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:140:15)
2014-05-03T01:48:07.047358+00:00 app[web.1]:     at EventEmitter.emit (events.js:98:17)
2014-05-03T01:48:07.047363+00:00 app[web.1]:     at net.js:440:14
2014-05-03T01:48:07.047364+00:00 app[web.1]:     at process._tickCallback (node.js:419:13)
2014-05-03T01:48:07.055494+00:00 app[web.1]: error: Forever detected script exited with code: 8
2014-05-03T01:48:05.437538+00:00 heroku[web.1]: Starting process with command `./node_modules/.bin/forever -m 5 server.js`

☔ heroku info --app xxx-stage

=== xxx-stage
Addons:        mandrill:starter
               mongohq:sandbox

Git URL:       git@heroku.xxx-stage.git
Owner Email:   heroku@michaelcole.com
Region:        us
Repo Size:     516k
Slug Size:     19M
Stack:         cedar
Web URL:       http://xxx-stage.herokuapp.com/

If I grunt I get:

grunt                                                                                                                                                                dev
Running "jshint:all" (jshint) task
>> 46 files lint free.

Running "concurrent:tasks" (concurrent) task
Running "watch" task
Waiting...
Running "nodemon:dev" (nodemon) task
[nodemon] v1.0.17
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node --debug server.js`
debugger listening on port 5858
Express app started on port 3000
amoshaviv commented 10 years ago

Hi @MichaelJCole,

It seems that your heroku app fails to connect to mongodb:

2014-05-03T01:48:07.047350+00:00 app[web.1]: Error: failed to connect to [localhost:27017]

Check your connection string in the config/env/production.js file.

MichaelJCole commented 10 years ago

Hi Amos,

I upgraded to 3.0, and noticed this message in the logs:

 NODE_ENV is not defined! Using default develpoment envrionment

I was able to deploy 3.0 pretty straight forward on Heroku. The only missing piece was to connect the DB by setting NODE_ENV

heroku config:set NODE_ENV=production --app xxx

Thanks for your help!