Search code examples
node.jsherokugeddy

GeddyJs (NodeJs framework) deploying to heroku cedar stack crashes


I have a geddyJs app that is crashing when starting..

the crash log is:

2013-02-14T04:04:19+00:00 heroku[run.4236]: Starting process with command `geddy -e production`
2013-02-14T04:04:19+00:00 app[web.1]: 
2013-02-14T04:04:19+00:00 app[web.1]: module.js:340
2013-02-14T04:04:19+00:00 app[web.1]:     throw err;
2013-02-14T04:04:19+00:00 app[web.1]:           ^
2013-02-14T04:04:19+00:00 app[web.1]: Error: Cannot find module '/app/config/true'
2013-02-14T04:04:19+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:338:15)
2013-02-14T04:04:19+00:00 app[web.1]:     at Function.Module._load (module.js:280:25)
2013-02-14T04:04:19+00:00 app[web.1]:     at Module.require (module.js:362:17)
2013-02-14T04:04:19+00:00 app[web.1]:     at require (module.js:378:17)
2013-02-14T04:04:19+00:00 app[web.1]:     at config.readConfig (/app/node_modules/geddy/lib/config.js:49:24)
2013-02-14T04:04:19+00:00 app[web.1]:     at _readConfig (/app/node_modules/geddy/lib/cluster/master.js:36:30)
2013-02-14T04:04:19+00:00 app[web.1]:     at async.AsyncBase.runItem (/app/node_modules/geddy/node_modules/utilities/lib/async.js:108:10)
2013-02-14T04:04:19+00:00 app[web.1]:     at async.AsyncBase.next (/app/node_modules/geddy/node_modules/utilities/lib/async.js:113:12)
2013-02-14T04:04:19+00:00 app[web.1]:     at Master.start (/app/node_modules/geddy/lib/cluster/master.js:257:11)
2013-02-14T04:04:19+00:00 app[web.1]:     at Object.utils.mixin.startCluster (/app/node_modules/geddy/lib/geddy.js:64:9)
2013-02-14T04:04:19+00:00 heroku[run.4236]: State changed from starting to up
2013-02-14T04:04:20+00:00 heroku[web.1]: Process exited with status 1
2013-02-14T04:04:20+00:00 heroku[web.1]: State changed from starting to crashed

My Procfile is:

web: geddy -e $NODE_ENV

My Package.json file is:

{
        "name": "new-gorelative",
        "version": "0.0.1",
        "auther": "Mike DeVita <[email protected]>",
        "dependencies": {
            "geddy": "0.6.x",
            "handlebars": "*"
        },
      "engines": {
        "node": "0.8.x",
        "npm": "1.1.x"
      }
}

Solution

  • i figured it out.

    Edit the config/production.js file and delete/comment the following lines(port, hostname)

    var config = {
      //port: '3000',
      // hostname: '0.0.0.0'
    };
    

    Add a app.js javascript file to your app's root directory, the configs set in this will override production.js

    var geddy = require('geddy');
    
    geddy.startCluster({
      hostname: process.env.IP || '127.0.0.1',
      port: process.env.PORT || '3000',
      // you can manually set this to production, or set an environment variable via heroku..
      environment: 'production'
      // just uncomment the below line, and delete the above line.
      // you will need to set an environment variable in heroku by running
      // heroku config:set NODE_ENV=production
      //environment: process.env.NODE_ENV || 'development'
    });
    

    Add a Procfile text file to your app's root directory

    web: node app.js
    

    remove the line for config\secrets.json in your .gitignore file - note: This is insecure, on public repo's as it exposes your cookie's secret hash.