EzDevInfo.com

heroku interview questions

Top heroku frequently asked interview questions

heroku - how to see all the logs

I have a small app on heroku. Whenever I want to see the logs I go to the command line and do

heroku logs

That only shows me about 100 lines. Is there not a way to see complete logs for our application on heroku?


Source: (StackOverflow)

How to empty DB in heroku

Im working on a RoR3 webapp on heroku. How do I empty the database?


Source: (StackOverflow)

Advertisements

Easy way to prevent Heroku idling?

In the Heroku free apps the dynos seem to keep idling - my app has very low traffic but it's also not really acceptable in my case that my users have to wait 20+ seconds to spin up a new dyno.

Frankly, with that kind of wait, many will leave before the first page even displays.

So, I have a problem: should I be paying $36 a month to save each user an embarrassingly long 20 seconds when my traffic is in the single-digits per day.

Is there a way around this??


Source: (StackOverflow)

How to reference images in CSS within Rails 4

There's a strange issue with Rails 4 on Heroku. When images are compiled they have hashes added to them, yet the reference to those files from within CSS don't have the proper name adjusted. Here's what I mean. I have a file called logo.png. Yet when it shows up on heroku it is viewed as:

/assets/logo-200a00a193ed5e297bb09ddd96afb953.png

However the CSS still states:

background-image:url("./logo.png");

The result: the image doesn't display. Anybody run into this? How can this be resolved?


Source: (StackOverflow)

How to stop an app on Heroku?

I have an app on Heroku which is being used by few users. However, I notice there are some data issues which i'd like to fix and stop the app in the mean time so users don't enter anything new.

Is there a way to stop the app on heroku rather than destroying it? I see that restart server command is there ...though I don't see anything like 'stop'


Source: (StackOverflow)

How to link a folder with an existing Heroku app

I have an existing Rails app on GitHub and deployed on Heroku. I'm trying to set up a new development machine and have cloned the project from my GitHub repository. However, I'm confused as to how to link this folder up to Heroku. Originally, I used the "heroku create" command, but obviously I don't want to do that since it will create another Heroku instance.


Source: (StackOverflow)

Connect to a heroku database with pgadmin

I would like to manage my heroku database with pgadmin client. By now, I've been doing this with psql. When I use data from heroku pg:credentials to connect de DB using pgadmin, I obtain:

An error has occurred:

Error connecting to the server: FATAL: permission denied for database "postgres" DETAIL: User does not have CONNECT privilege.

Any guide on how to achieve the connection?


Source: (StackOverflow)

renamed heroku app from website, now it's not found

After renaming my heroku app from the heroku website, whenever I cd to it's directory in a terminal and run any heroku command, I get App not found. Does anybody know of a way to remedy this?


Source: (StackOverflow)

Change from SQLite to PostgreSQL in a fresh Rails project

I have a rails app that's databases are in SQLite (The dev and production). Since I am moving to heroku, I want to convert my database to PostgreSQL.

Anyways, I heard that the local, development, database does not need to be changed from SQLite, so I don't need to change that, however, how do I go about changing the production environment from SQLite to PostgreSQL?

Has anyone ever done this before and can help?

P.S. I'm not sure what exactly this process is called, but I've heard about migrating the database from SQLite to PostgreSQL, is that what needs to be done?


Source: (StackOverflow)

Permission denied (publickey) when deploying heroku code. fatal: The remote end hung up unexpectedly

I'm attempting to deploy my code to heroku with the following command line:

git push heroku master

but get the following error:

Permission denied (publickey).
fatal: The remote end hung up unexpectedly

I have already uploaded my public SSH key, but it still comes up with this error.


Source: (StackOverflow)

Heroku free account limited?

Currently, I am running wordpress as my blog engine on free hosting, but I'm planning to move to use git-based blog engine(Jekyll, Toto) on Ruby platform. Then I see Heroku provides free account features, but I don't see any detail on bandwidth, disk spaces, requests?


Source: (StackOverflow)

Why do people use Heroku when AWS is present? What's distinguishing about Heroku

I'm a beginner RoR programmer who's planning to deploy my app using Heroku. Word from my other advisor friends says that Heroku is really easy, good to use. The only problem is that I still have no idea what Heroku does..

I've looked at their website and in a nutshell, what Heroku does is help with scaling but... why does that even matter? How does Heroku help with:

  1. Speed - My research implied that deploying AWS on the US East Coast would be the fastest if i am targeting a US/Asia based audience

  2. Security - How secure are they?

  3. Scaling - How does it actually work?

  4. Cost efficiency - There's something like a dyno that makes it easy to scale.

  5. How do they fare against their competitors? For example, Engine Yard and bluebox?

Please use layman English terms to explain... I'm a beginner programmer. Thank you.


Source: (StackOverflow)

Should I check in node_modules to git when creating a node.js app on Heroku?

I followed the basic getting started instructions for node.js on Heroku here:

https://devcenter.heroku.com/categories/nodejs

These instruction don't tell you to create a .gitignore node_modules, and therefore imply that node_modules should be checked in to git. When I include node_modules in git my getting started application ran correctly.

When I followed the more advanced example at:

https://devcenter.heroku.com/articles/realtime-polyglot-app-node-ruby-mongodb-socketio https://github.com/mongolab/tractorpush-server (source)

It instructed me to add node_modules to .gitignore. So I removed node_modules from git, added it to .gitignore, then re-deployed. This time the deployed failed like so:

-----> Heroku receiving push
-----> Node.js app detected
-----> Resolving engine versions
       Using Node.js version: 0.8.2
       Using npm version: 1.0.106
-----> Fetching Node.js binaries
-----> Vendoring node into slug
-----> Installing dependencies with npm
       Error: npm doesn't work with node v0.8.2
       Required: node@0.4 || 0.5 || 0.6
           at /tmp/node-npm-5iGk/bin/npm-cli.js:57:23
           at Object.<anonymous> (/tmp/node-npm-5iGk/bin/npm-cli.js:77:3)
           at Module._compile (module.js:449:26)
           at Object.Module._extensions..js (module.js:467:10)
           at Module.load (module.js:356:32)
           at Function.Module._load (module.js:312:12)
           at Module.require (module.js:362:17)
           at require (module.js:378:17)
           at Object.<anonymous> (/tmp/node-npm-5iGk/cli.js:2:1)
           at Module._compile (module.js:449:26)
       Error: npm doesn't work with node v0.8.2
       Required: node@0.4 || 0.5 || 0.6
           at /tmp/node-npm-5iGk/bin/npm-cli.js:57:23
           at Object.<anonymous> (/tmp/node-npm-5iGk/bin/npm-cli.js:77:3)
           at Module._compile (module.js:449:26)
           at Object.Module._extensions..js (module.js:467:10)
           at Module.load (module.js:356:32)
           at Function.Module._load (module.js:312:12)
           at Module.require (module.js:362:17)
           at require (module.js:378:17)
           at Object.<anonymous> (/tmp/node-npm-5iGk/cli.js:2:1)
           at Module._compile (module.js:449:26)
       Dependencies installed
-----> Discovering process types
       Procfile declares types -> mongod, redis, web
-----> Compiled slug size is 5.0MB
-----> Launching... done, v9

Running "heroku ps" confirms the crash. Ok, no problem, so I rolled back the change, add node_module back to the git repository and removed it from .gitignore. However, even after reverting, I still get the same error message on deploy but now the application is running correctly again. Running "heroku ps" tells me the application is running.

So my question is what's the right way to do this? Include node_modules or not? And why would I still be getting the error message when I rollback? My guess is the git repository is in a bad state on the Heroku side?


Source: (StackOverflow)

how to push different local git branches to heroku/master

Heroku has a policy of ignoring all branches but 'master'.

While I'm sure Heroku's designers have excellent reasons for for this policy (I'm guessing for storage and performance optimization), the consequence to me as a developer is that whatever local topic branch I may be working on, I would like an easy way to switch Heroku's master to that local topic branch and do a "git push heroku -f" to over-write master on Heroku.

What I got from reading the "Pushing Refspecs" section of http://progit.org/book/ch9-5.html is

git push -f heroku local-topic-branch:refs/heads/master

What I'd really like is a way to set this up in the config file so that "git push heroku" always does the above, replacing local-topic-branch with the name of whatever my current branch happens to be. If anyone knows how to accomplish that, please let me know!

The caveat for this, of course, is that this is only sensible if I am the only one who can push to that Heroku app/repository. A test or QA team might manage such a repository to try out different candidate branches, but they would have to coordinate so that they all agree on what branch they are pushing to it on any given day.

Needless to say, it would also be a very good idea to have a separate remote repository (like Github) without this restriction for backing everything up to. I'd call that one "origin" and use "heroku" for Heroku so that "git push" always backs up everything to origin, and "git push heroku" pushes whatever branch I'm currently on to Heroku's master branch, overwriting it if necessary.

Can anybody tell me if this would work?

[remote "heroku"]
    url = git@heroku.com:my-app.git
    push = +refs/heads/*:refs/heads/master

I'd like to hear from someone more experienced before I begin to experiment, although I suppose I could create a dummy app on Heroku and experiment with that.

As for fetching, I don't really care if the Heroku repository is write-only. I still have a separate repository, like Github, for backup and cloning of all my work.

Footnote: This question is similar to, but not quite the same as http://stackoverflow.com/questions/1489393/good-git-deployment-using-branches-strategy-with-heroku


Source: (StackOverflow)

Heroku error: "Permission denied (public key)"

I keep getting this error. I am using Mac. I generated a key and added it to heroku using

heroku config:add key="ssh-rsa blahblah=me@me.com"

But this doesn't work. I keep getting the same error. Short of reinstalling ssh-keygen, what can I do about this?


Source: (StackOverflow)