Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Foreman - Essential Rails Gems

Foreman - Essential Rails Gems

Continuation of @jwo's essential Rails gems series, Foreman is a command line tool for Processes and Environment Variables.

Presented at Houston Ruby Brigage

Jesse Wolgamott

January 15, 2013
Tweet

More Decks by Jesse Wolgamott

Other Decks in Programming

Transcript

  1. Command Line Tool Command Line Tool for Procfile Apps Environment

    Variable manager Wait, what is a Procfile? Wednesday, February 6, 13
  2. Procfile. a way to: start multiple processes at once tell

    Heroku what processes to start make things easy on new developers web: bundle exec puma -p $PORT worker: bundle exec sidekiq Wednesday, February 6, 13
  3. Onboarding Devs OK, so you want to start SOLR, and

    Memcached, and then rake jobs:work. Then run rails s New Way: foreman start Wednesday, February 6, 13
  4. Complicated Procfile web: bundle exec unicorn_rails -p $PORT solr: bundle

    exec rake sunspot:solr:run worker: bundle exec rake environment resque:work QUEUE=* memcached: service start memcached redis: sevice start redis foreman start Wednesday, February 6, 13
  5. But Wait. There’s more! Environment Variables Rule Keeps sensitive information

    out of code Gives developer their own S3 bucket and stuff Works extraordinarily well with Heroku Helps follow http://www.12factor.net/ Wednesday, February 6, 13
  6. .env - How to use? S3_BUCKET_NAME=jwo-nuttin S3_ACCESS_KEY_ID=UXTISD6D7Q S3_SECRET_ACCESS_KEY=XXXXXXXXXXXXXKhpoNJCJdT7zvz4Kv1A71eUqxtJR RACK_ENV=development S3_BUCKET_NAME=

    S3_ACCESS_KEY_ID= S3_SECRET_ACCESS_KEY= RACK_ENV= commit your .env.sample file .gitignore your .env file Wednesday, February 6, 13
  7. in Ruby / Rails Fog.configure do |config| config.directory_name = ENV['S3_BUCKET_NAME']

    end # or Super Fancy Pants: Fog.configure do |config| config.directory_name = ENV.fetch('S3_BUCKET_NAME') { raise ArgumentError.new “Missing S3 BUCKET NAME” } end Wednesday, February 6, 13
  8. Rails Console `rails c` won't automagically set your ENV `foreman

    run rails c` WILL OR... Use the `heroku-dev-env` gem to load .env automatically Wednesday, February 6, 13