Skip to content

Instantly share code, notes, and snippets.

@sseletskyy
Created October 9, 2013 12:21
Show Gist options
  • Save sseletskyy/6900397 to your computer and use it in GitHub Desktop.
Save sseletskyy/6900397 to your computer and use it in GitHub Desktop.
Heroku related notes

#Toolbelt $ heroku login Enter email + password

$ heroku create

check git configuration $ git config -e

deploy the code from local branch "master" $ git push heroku master

deploy the code from local branch "yourbranch" $ git push heroku yourbranch:master

in case of crash: "rake aborted! could not connect to server: Connection refused Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5432?"

$ heroku labs:enable user-env-compile or $ heroku labs:disable user-env-compile $ heroku labs:enable user-env-compile

migration $ heroku run rake db:migrate

You can check the state of the app’s dynos. The heroku ps command lists the running dynos of your application $ heroku ps

set one dyno running the web process type $ heroku ps:scale web=1

visit the app in our browser with heroku open $ heroku open

view logs $ heroku logs $ heroku logs --tail

console $ heroku run rails console

Runtime dependencies on development/test gems

$ heroku run rake -T Running bundle exec rake -T attached to terminal... up, ps.3 rake aborted! no such file to load -- rspec/core/rake_task Then you’ve hit this problem. First, duplicate the problem locally: $ bundle install --without development:test

$ bundle exec rake -T rake aborted! no such file to load -- rspec/core/rake_task Now you can fix it by making these Rake tasks conditional on the gem load. For example: Rakefile begin require "rspec/core/rake_task"

desc "Run all examples"

RSpec::Core::RakeTask.new(:spec) do |t| t.rspec_opts = %w[--color] t.pattern = 'spec/**/*_spec.rb' end rescue LoadError end

Confirm it works locally, then push to Heroku.

##Phusion Passenger Create Procfile in the root of the project with this content

web: bundle exec passenger start -p $PORT --max-pool-size 3

Configuration

  • --max-pool-size - The maximum number of worker processes to run. The maximum number that you can run depends on the amount of memory your dyno has.
  • --min-instances - If you don't want the number of worker processes to scale dynamically, then use this option to set it to a value equal to --max-pool-size.
  • --spawn-method - By default, Phusion Passenger preloads your app and utilizes copy-on-write (the "smart" spawning method). You can disable this by setting this option to direct.
  • --no-friendly-error-pages - If your app fails to start, Phusion Passenger will tell you by showing a friendly error page in the browser. This option disables it.

#Foreman Run your app locally with Foreman: $ foreman start 18:06:23 web.1 | started with pid 47219 18:06:23 worker.1 | started with pid 47220 18:06:25 worker.1 | (in /Users/adam/myapp) 18:06:27 web.1 | => Awesome web application server output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment