Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment on Heroku... #52

Closed
timstephenson opened this issue Mar 19, 2012 · 11 comments
Closed

Deployment on Heroku... #52

timstephenson opened this issue Mar 19, 2012 · 11 comments

Comments

@timstephenson
Copy link

I think I'm close to having a test deployed on heroku. Sorry I keep bugging you.

I configured my heroku app with the MongoHQ add on. What I get for a connection is

MONGOHQ_URL => mongodb://heroku:[email protected]:10076/appBLABLA

In my database.coffee file, I tried adding this as the host:

process.env.MONGOHQ_URL

But I end up with an error:

node.js:201
    2012-03-19T21:56:35+00:00 app[web.1]:         throw e; // process.nextTick error, or 'error' event on first tick
    2012-03-19T21:56:35+00:00 app[web.1]:               ^
    2012-03-19T21:56:35+00:00 app[web.1]: Error: failed to connect to   [mongodb://heroku:[email protected]:10076/appBLABLA:27017]
2012-03-19T21:56:35+00:00 app[web.1]:     at [object Object].emit (events.js:88:20)
2012-03-19T21:56:35+00:00 app[web.1]:     at [object Object].<anonymous>  (/app/node_modules/mongodb/lib/mongodb/connection/server.js:408:73)

I assume I need to configure a connection uri instead of the host and port, but I'm not sure where to go about doing this. Any advice would be greatly appreciated.

@timstephenson
Copy link
Author

I tried doing this too:

production
  name: "appBLABLA"
  port: 10076
  host: "mongodb://heroku:[email protected]"

Should the user name and password go somewhere else?

@lancejpollard
Copy link
Member

I haven't handled the url case yet, but you can do this:

# config/databases.coffee
module.exports =
  mongodb:
    development:
      name: "example-development"
      port: 27017
      host: "127.0.0.1"
    test:
      name: "example-test"
      port: 27017
      host: "127.0.0.1"
    staging:
      name: "example-staging"
      port: 27017
      host: "127.0.0.1"
    # mongodb://heroku_app123123123:[email protected]:33591/heroku_app123123123
    production:
      name: "heroku_app123123123"
      port: 33591
      host: "ds077519.mongolab.com"
      username: "heroku_app123123123"
      password: "ajsdifjasdfklasjdfa"

Does that work?

@timstephenson
Copy link
Author

Hi Thanks.

Yes it worked. I'm getting close now. The app works, but the bootstrap assets, css etc aren't available. I ran cake assets:bundle and then committed the assets to the repo. For testing purposes is it possible to just include the assets, or should they always be uploaded to s3?

Thank you very much for your help.

@lancejpollard
Copy link
Member

Nice!

Yeah, I got a little carried away in not wanting to commit "compiled" things to repos and added the public/assets folder to the .gitignore (I'll make that opt-in in the next release):

https://github.com/viatropos/tower/blob/master/lib/tower/server/generator/generators/tower/app/templates/gitignore

So, just open that file, remove those lines, re-commit, and re-push your code, should work then.

cd your-project
mate .gitignore

@timstephenson
Copy link
Author

Thanks. I changed the .gitignore file, but no luck. I noticed that if I run node server.js -e production locally that it does the same thing as on heroku. I think I must have missed a step somewhere.

I'll review the docs. I noticed the files in the assets directory are binary. Should I not have done the cake assets:bundle step? Thanks again for all the advice.

Best

@lancejpollard
Copy link
Member

Oh ok you're right, looks like the http headers for gzip still haven't been updated.

#37

Try doing what he did and comment out the gzip code. I will fix this soon, but the default should gzip since it's the most optimized. Basically, if you get rid of gzip the node server will serve the minified version properly, and heroku should show them.

If you get through this I'd love to get a pull request with fixes.

Let me know how it goes.

@timstephenson
Copy link
Author

Thanks. I'll let you know how it goes and hopefully get a pull request for you.

@lancejpollard
Copy link
Member

You can try these two plugins, see if they allow you to serve gzipped files locally:

I don't have the time at the moment to test this out, but that's where I'd start to get gzipping working.

@timstephenson
Copy link
Author

Cool. Thanks. I'll take a look this evening and tomorrow.

@timstephenson
Copy link
Author

Still working on it. Got busy so I haven't finished. A couple notes.

I tried using both gzippo and connect-gzip by adding to the tower/server/application.js file

gzippo = require('gzippo');

or

gzip = require('connect-gzip');

And then changing this.use(connect.static(Tower.publicPath to:

    this.use(gzip.staticGzip(Tower.publicPath, {
      maxAge: Tower.publicCacheDuration
    }));

testing both, this one is for connect-gzip. Am I in the right area?

Also, I noticed that if I comment out ./node_modules/tower/lib/server/application/assets.js, line 60

// return gzip(result, function(error, result) {
  fs.writeFileSync(digestPath, result);
  return next();
// });

And bundle the assets, then run locally as production, I get some css, but there is javascript error "ReferenceError: Can't find variable: DesignIO"

Where should I look for that.

Hopefully I'll have more time in the next couple of days and I can continue working on it.

Thanks

@Voronchuk
Copy link
Contributor

I recommend to add stuff about MongoHQ config settings here: https://github.com/viatropos/tower/wiki/heroku

Have to search all issues to solve same trouble

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

No branches or pull requests

3 participants